Welcome Guest, Not a member yet? Register   Sign In
Hostgator mod_rewrite with CI
#1

[eluser]fry-guy[/eluser]
Hi All,

I recently got some space off Hostgator and the .htaccess file that I use for my CI apps on other servers does not seems to work on Hostgator.

I searched Hostgator forums and found out that they use:

Quote:HostGator uses PHPSuExec/SuPHP

Would that make a difference in the .httaccess rules are written. Here is the .htaccess file that I am using.

Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    RewriteCond $1 !^(index\.php|public|tmp|images|captcha|js|css|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    RewriteRule /favicon\.ico /images/favicon.ico [L]

    SetEnv mod_rewrite_enabled 1
</IfModule>
<IfModule !mod_rewrite.c>
    SetEnv mod_rewrite_enabled 0
</IfModule>

The problem I have noticed is that after removing 'index.php' from the config file, when I try to access other controllers, it always takes me back to the homepage. But if I add '/index.php/controller' then it works although 'index.php' has been removed from the config file.

Any ideas what might be wrong or anyone here who is on Hostgator and using .htaccess

Many thanks

Cheers
fry
#2

[eluser]fry-guy[/eluser]
Hi,

I have found the solution to this problem. This happens only when you create a reseller account. You need to add your account username to the re-write base. Below is a sample of my .htaccess file

Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /~ivalves/

    RewriteCond $1 !^(index\.php|public|tmp|images|captcha|js|css|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

    SetEnv mod_rewrite_enabled 1
</IfModule>
<IfModule !mod_rewrite.c>
    SetEnv mod_rewrite_enabled 0
</IfModule>

/~ivalves/ being the account username

Hope this will be helpful to someone.
#3

[eluser]ervinter[/eluser]
Hi fry-guy,

I tried your solution on my share hosting in HostGator, but it seem like not working properly when I try to called other controller it always redirect back to main index controller.

Any clue on this?

Thanks a lot.
#4

[eluser]fry-guy[/eluser]
can you please post your .htaccess file
#5

[eluser]setiawans[/eluser]
I had experienced similar problem, however i'm using Hostmonster, I was able to solve the problem by changing config.php at
Code:
$config['uri_protocol']    = "AUTO";
to
Code:
$config['uri_protocol']    = "REQUEST_URI";

I was changing many times .htaccess but it was no luck until i changed the code as above.
#6

[eluser]Josh Giese[/eluser]
[quote author="setiawans" date="1216831552"]I had experienced similar problem, however i'm using Hostmonster, I was able to solve the problem by changing config.php at
Code:
$config['uri_protocol']    = "AUTO";
to
Code:
$config['uri_protocol']    = "REQUEST_URI";

I was changing many times .htaccess but it was no luck until i changed the code as above.[/quote]


wow! that worked for me. I recently changed dedicated servers, and after i did my routing wasnt working. I did what you suggested and changed
$config['uri_protocol'] = "AUTO";
to
$config['uri_protocol'] = "REQUEST_URI";

now everything is working. thanks!
#7

[eluser]edoc[/eluser]
Thanks setiawans, your solution worked for me as well, I'm using Justhost.
#8

[eluser]Unknown[/eluser]
yes it works
just change
Code:
$config['uri_protocol'] = 'REQUEST_URI';


the code in htaccess file is as below
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /


    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

  
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
  
</IfModule>



The Problem is solved enjoy... :blank:




Theme © iAndrew 2016 - Forum software by © MyBB