Part of the EllisLab Network
   
1 of 2
1
htaccess for PHP-CGI hosting (and use segments with query strings)
Posted: 07 November 2008 10:11 PM   [ Ignore ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3198
Joined  06-10-2007

This custom .htaccess setup allows you to use uri segments and query strings together and may fix the issue everyone seems to have running CI on PHP-CGI hosting.

The great thing is that CI allows us to use a custom defined uri protocol. (thanks Rick Ellis)

If you want to try this setup then read on.

Set your custom uri protocol in application/config.php

$config['uri_protocol'"APP_PATH";

//enable query strings if required.
$config['enable_query_strings'TRUE

Create your .htaccess file like so

RewriteEngine On

RewriteBase 
/

RewriteCond %{ENV:REDIRECT_APP_PATH} !^$
RewriteRule ^(.*)$ - [E=APP_PATH:%{ENV:REDIRECT_APP_PATH}]

RewriteCond 
%{ENV:APP_PATH} ^$
RewriteRule ^(.*)$ - [E=APP_PATH:/$1]

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

You should be good to go. Good luck.

Credit goes to the folks @ TinyMVC forum for this solution.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

Profile
 
 
Posted: 08 November 2008 04:59 AM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

That is some dope-ass shit, wired. Good on ya’ mate!

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 14 December 2008 12:36 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Avatar
Total Posts:  23
Joined  08-28-2008

nice, this one works!
I’m making a repost on my site.

cool ^_^

 Signature 

http://www.ikawka.com/

Profile
 
 
Posted: 08 March 2010 02:25 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  22
Joined  05-14-2009

it works for me partially. Now I can at least get into my home page. But that’s it. From there what ever link I click it refreshes the home page even thought the URL changes according to the new link I clicks.

Any help?

Profile
 
 
Posted: 10 March 2010 04:35 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  224
Joined  03-21-2006

Mine seems to work with just the two config changes. Is the .htaccess required or only in certain circumstances?

Profile
 
 
Posted: 08 April 2010 01:05 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  1
Joined  03-01-2010

Thank you so much. My application was working fine on my local server, but when I uploaded it to my hosting server it broke. And it all had to do with my hosting server running PHP-CGI.

One thing I’ve noticed is that my application loads slower now that I’ve implemented this solution. Does anyone know why this happens or have a way to speed thing up.

Profile
 
 
Posted: 25 June 2010 05:35 AM   [ Ignore ]   [ # 6 ]  
Grad Student
Rank
Total Posts:  32
Joined  05-03-2010

Thanks mate… Thanks a lot!

Luis

Profile
 
 
Posted: 09 August 2010 08:47 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
RankRank
Total Posts:  138
Joined  04-21-2006

Is there a way to make this work with CI 2.0? At the moment all system written links (redirect, pagination) get a additional /?/ added to the front.

Profile
 
 
Posted: 26 August 2010 04:22 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  4
Joined  08-26-2010

should this approach add an APP_PATH variable to $_SERVER?

i try this, but everything seems to just redirect to the default controller, so the homepage only.

actually if i change the $config[‘uri_protocol’]  = “REDIRECT_APP_PATH”;

it does work. is this the wrong approach?

Profile
 
 
Posted: 05 January 2011 08:43 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  4
Joined  08-26-2008

This will not work when you have your controller in subfolder? controller/admin/home.php

 Signature 

www.blog.insicdesigns.com

Profile
 
 
Posted: 11 January 2011 05:20 AM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  1
Joined  01-11-2011

Hello,

I think I’m having the same problem as you, insic2.0. Everything works except for login, I have a 500 error (/login/connexion) online, but it works on my local server…

Did you find a solution ?

Thank you

Profile
 
 
   
1 of 2
1