Htaccess "no input file specified"


#1

getting the “no input file specified error” trying to rewrite URLs in htaccess with

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

Have tried

RewriteRule ^(.*)$ index.php?/$1 [L]

but it just sends all requests to the main page. I have also tried other variations, such as

RewriteRule .* index.php/$0 [PT,QSA,L]

and adding

Options +FollowSymLinks
Options -MultiViews

but nothing I do can get it to work.

Any suggestions?

Thanks!


#2

Add a RewriteBase directive when using mod_rewrite in .htaccess files.

But your problem has to deal with how PHP is configured on the web server.

For example on my machine PHP by default runs CGI/FastCGI version 5.2.6 and those directives work just fine according to phpinfo() eg:

Loaded configuration file = /etc/php5/cgi/php.ini
_SERVER[“SCRIPT_FILENAME”] /home/username/domain/index.php
_SERVER[“REQUEST_URI”] = /nothing
_SERVER[“SCRIPT_NAME”] = /nothing
_SERVER[“PATH_INFO”] = /nothing
_SERVER[“PATH_TRANSLATED”] = /home/username/domain/nothing
_SERVER[“ORIG_PATH_INFO”] = /index.php/nothing
_SERVER[“ORIG_SCRIPT_NAME”] /cgi-system/php5.cgi
_SERVER[“ORIG_SCRIPT_FILENAME”] /dh/cgi-system/php5.cgi
_SERVER[“ORIG_PATH_TRANSLATED”] /home/username/domain/index.php/nothing

Are you using a different version of PHP or a customized PHP configuration file?

Customer since 2000 :cool: openvein.org


#3

Thanks!

I’ve tried with and without RewriteBase, and it doesn’t seem to have an effect, but I will be sure to put it back in since I didn’t mean to remove it permanently. Then again, I’m no pro with this stuff. If my .htaccess is in a subdirectory, “subdir”, and I want to rewrite

http://www.site.com/subdir/page/foo

to

http://www.site.com/subdir/index.php/page/foo

should I have

RewriteBase /

or

RewriteBase /subdir/ ?

On my machine, PHP 5.2.9 is running as CGI/FastCGI with Loaded Configuration File /etc/php5/cgi/php.ini. No custom php.ini used.

After several days working on this, I’m about to lose it and just forget the pretty URLs, and recode the app! lol

Thanks again for any and all advice!


#4

[quote]should I have

RewriteBase /

or

RewriteBase /subdir/ ?[/quote]
It should be /subdir/ since that is the directory the .htaccess is located in relative to the document root.

Well I don’t have experience with 5.2.9 yet but check phpinfo() again, there is a section ‘cgi-fcgi’ and mine says:cgi.check_shebang_line 1 cgi.fix_pathinfo 1 cgi.force_redirect 1 cgi.nph 0 cgi.redirect_status_env no value cgi.rfc2616_headers 0 fastcgi.logging 1And after moving both index.php and .htaccess to /home/username/domain/subdir/ and setting RewriteBase to /subdir/ this still works for me with 5.2.6

Try this. Just rewrite to index.php without adding the /$1

For me index.php still gets called of course but PATH_INFO and PATH_TRANSLATED are not set, so there won’t be a value of ‘/$1’ set anywhere. BTW if you are just trying to make search engine friendly URLs just rewrite to a query string, ie index.php?path=$1. Seems like getting PATH_INFO to work as expected is harder for PHP to do than one expects. Don’t have this much trouble in with Perl at least.

Oh yeah don’t forget if you have .htaccess in the parent directory then that will affect /subdir too so you might be seeing a side effect.

Customer since 2000 :cool: openvein.org


#5

Looks like its a bug with the 5.2.9 public release:
http://bugs.php.net/bug.php?id=47042

So not much you can do to get it fixed other than install a patched 5.2.9 downgrade to 5.2.6 or wait for DH to upgrade to 5.3

Customer since 2000 :cool: openvein.org


#6

Thanks again for all your help, Atropos, on the RewriteBase and the mod_rewrite. I’ll follow up on your suggestions and post back. That it all might come down to a bug with 5.2.9 is a little painful…Cheers.


#7

Couldn’t make anything work, but then changed PHP to run as CGI instead of FastCGI, and it all works with the straightforward rewrite:

RewriteEngine On
RewriteBase /subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

I’m not aware of any extreme negative side effects with the change to “PHP 5 CGI” instead of FastCGI that outweigh the benefit, for me, of the nicer URLs I get with the rewrite. Of course, I’m fully willing to be educated on this :slight_smile:

Thanks for all the suggestions.