My current host uses FastCGI for its PHP setup, and this is apparently causing some issues when a mod_rewrite directive redirects to a URL with a PATH_INFO portion. For example, there are issues when using the following:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
When using the above, navigating to a rewritten URL results in the 'No input file specified." error message from PHP, meaning that PHP wasn't appropriately passed a file to parse.
I've been able to learn from web searches that this issue only appears when PHP is being run under FastCGI, but what I haven't been able to find a straight answer on is why. Instead, the web is apparently filled with people who blindly change the rewrite to use a query string (e.g. changing the index.php/$1
portion of the above to index.php?/$1
- note the ?
) without actually understanding the underlying problem.
I know that the issue is occuring as a part of, or as a result of, the rewriting process, and that it is not a problem of FastCGI installs being unable to handle PATH_INFO URLs at all, since the $_SERVER['PATH_INFO']
variable is populated appropriately when I navigate directly to www.example.com/index.php/foobar
without going through the rewrite process.
Could someone please explain what is happening during the rewrite and subsequent hand-off to PHP that is causing the failure?