404 error and PHP - No input file specified


I am sure many of you have already run across this bug, but I have not found a solution yet. The problem is, when a PHP URL is specified that does not exist, a page returns with the text, “No input file specified.” rather than the 404 message. I have a custom 404 page defined, and this works for all bad URLs, except for PHP. What is the fix?


I would like to expand on this as I think it is related. Accessing a redirected page will display a message such as permanent move with a link, rather than being redirected.
This occurs when accessing a url with curl and the redirect is in the htaccess file.


I can’t speak to the redirection thing you are talking about, but I got this answer from tech support:

Add these lines to your .htaccess file:

RewriteEngine On
RewriteRule ^.+.php$ /bogusfile

and your custom error page will start coming up for php files. The problem arises from PHP as CGI passing anything that ends in .php off directly to the PHP interpreter. This checks to see if a file exists and if it’s extension is PHP.

I am probably going to add the above information into the wiki since I am sure many others have run into this, and maybe they don’t even know it yet.


I just redirect to my normal PHP 404 page.

RewriteEngine on
Rewritecond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule .php$ /404.php

That assumes you have a custom 404 error page named 404.php.

Then, in 404.php, I add this code at the top to make sure it returns a 404 code instead of 200:

header(“HTTP/1.1 404 Not Found”);

:stuck_out_tongue: Save up to $96 at Dreamhost with the 96DOLLARSOFF promo code.


See the documentation at curl_setopt – Set an option for a CURL transfer

TRUE to follow any "Location: " header that the server sends as part of the HTTP header (note this is recursive, PHP will follow as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set).

:cool: Perl / MySQL / HTML+CSS


I should have known that. I remember reading about that option. I guess it just didn’t click.