简体   繁体   中英

mod_rewrite “No input file specified” error

Here is the situation: I have got ancient PHP scripts working fine on "old" server (Apache/2.2.3, PHP as module) and I need to move it to "new" server (Apache/2.2.16 (Debian), PHP as fcgi/suhoshin)...at least my ISP tells so.

I have got very simple .htaccess file that works fine on "old" server:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/css   #Just an exception for domain.com/css dir
RewriteRule ^([^/]+)/?$  %{DOCUMENT_ROOT}/index.php/$1 [NE,L]

From what I studied mod_rewrite docs and site behaviour, when

  • domain.com/aaa/ opened, it rewrites/opens a script as if called domain.com/index.php/aaa/
  • domain.com/?a=1&b=2 opened, it rewrites/opens a script as if called domain.com/index.php/?a=1&b=2

etc., optinal slash at the end of the URL. Other "301" redirects are made in PHP according to a database results/settings, that is not important now.

Now my problem is: When I transfer this .htaccess file + PHP scripts to the "new" server, I get this error message in browser:

No input file specified.

I have been trying several hours and studying regular expressions and Apache docs, but I cannot make it working. I guess there is something different in Apache2 configuration on both servers, but cannot find what that is. Have even tried to put echo at the beginning of the index.php to make sure this error does not come from PHP, but no :-( I am sure .htaccess support is on as I can generate errors when putting wrong directive. Not a regular_expressions guru. Can anybody help please?

UPDATE: Solved by changing it to:

RewriteRule ^([^/]+)/?$  %{DOCUMENT_ROOT}index.php [NE,L]

Insteresting that /$1 is not necessary, however I had to change PHP too to $_SERVER["REQUEST_URI"] from $_SERVER["PATH_INFO"].

Can you try this code:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !^/css [NC]
RewriteRule ^([^/]+)/?$ /index.php/$1 [NE,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM