CodeIgniter 2 no longer able to use PATH_INFO after modifying .htaccess
I'm brand new to CI and I'm trying to remove the annoying "index.php" from the URLs. This is the .htaccess I'm using:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
As you can see, I have to use QUERY_STRING
to make the new URL work (note the question mark after index.php). When I try to use PATH_INFO
(i.e. without the question mark), I only get No input file specified
error.
This is fine, and I'm OK with using QUERY_STRING
if I have to, but I don't understand the problem because I was using PATH_INFO
just fine before I started playing with the rewrite - i.e. the default of "example.com/index.php/controller/f开发者_高级运维unction" was working, and that uses PATH_INFO AFAIK.
Does anyone know why the htaccess breaks PATH_INFO in my example? Sorry for the stupid question.
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php/%{REQUEST_URI} [L]
The rewrite rules above seem to work fine for an app that I'm currently working on... they pass the correct GET requests along with the proper PATH_INFO values.
精彩评论