Part of the EllisLab Network
   
 
Hostgator mod_rewrite with CI
Posted: 11 June 2008 04:01 PM   [ Ignore ]  
Summer Student
Total Posts:  9
Joined  01-11-2007

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:

HostGator uses PHPSuExec/SuPHP

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

<IfModule mod_rewrite.c>
    
RewriteEngine on
    RewriteBase 
/

    
RewriteCond $!^(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

Profile
 
 
Posted: 08 July 2008 02:33 AM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  9
Joined  01-11-2007

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

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

    
RewriteCond $!^(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.

Profile
 
 
Posted: 22 July 2008 10:49 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Avatar
Total Posts:  23
Joined  07-18-2008

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.

 Signature 

Ervin Ter Blog Twitter

Profile
 
 
Posted: 23 July 2008 01:33 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  9
Joined  01-11-2007

can you please post your .htaccess file

Profile
 
 
Posted: 23 July 2008 07:45 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  12
Joined  03-14-2007

I had experienced similar problem, however i’m using Hostmonster, I was able to solve the problem by changing config.php at

$config['uri_protocol']    "AUTO"

to

$config['uri_protocol']    "REQUEST_URI"

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

Profile
 
 
Posted: 12 January 2009 02:54 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Avatar
Total Posts:  29
Joined  12-27-2007
setiawans - 23 July 2008 11:45 AM

I had experienced similar problem, however i’m using Hostmonster, I was able to solve the problem by changing config.php at

$config['uri_protocol']    "AUTO"

to

$config['uri_protocol']    "REQUEST_URI"

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


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!

 Signature 

JoshGiese.com

Profile