CodeIgniter Forums
htaccess for PHP-CGI hosting (and use segments with query strings) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: htaccess for PHP-CGI hosting (and use segments with query strings) (/thread-13028.html)

Pages: 1 2


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 11-07-2008

[eluser]wiredesignz[/eluser]
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
Code:
$config['uri_protocol'] = "APP_PATH";

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

Create your .htaccess file like so
Code:
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.


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 11-08-2008

[eluser]Colin Williams[/eluser]
That is some dope-ass shit, wired. Good on ya' mate!


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 12-14-2008

[eluser]pixelazion[/eluser]
nice, this one works!
I'm making a repost on my site.

cool ^_^


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 03-08-2010

[eluser]thoque[/eluser]
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?


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 03-10-2010

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


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 04-08-2010

[eluser]Unknown[/eluser]
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.


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 06-25-2010

[eluser]luisfmgoncalves[/eluser]
Thanks mate... Thanks a lot!

Luis


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 08-09-2010

[eluser]sqwk[/eluser]
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.


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 08-26-2010

[eluser]kungfun[/eluser]
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?


htaccess for PHP-CGI hosting (and use segments with query strings) - El Forum - 01-05-2011

[eluser]insic2.0[/eluser]
This will not work when you have your controller in subfolder? controller/admin/home.php