Reputation: 10892
I have made a custom 404 page and inserted in my htaccess file:
ErrorDocument 404 /404.php
And the error direct works properly whenever I test a url with no extension or an .html extension. However, when I type in a url with a .php extension, a blank page with the message "No input file specified." pops up.
What do I have to do to make my custom 404 page pop up for .php file extensions as well?
Upvotes: 0
Views: 2938
Reputation: 12834
This happens when PHP is compiled as a CGI Binary
in your server. In such cases even if you have apache
404 defined, the request for PHP gets passed over to the CGI binary
which gives this error when the file to process is not found (No input file specified
).
The solution to this problem will vary based on various other config params, but essentially what you should try to do is first check the URL, and if it does not exist, translate it into a non-php url so that the rule kicks in and shows the correct 404.
Not tested but something in the lines of:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule ^.+\.php$ /non_existant_file
Upvotes: 2
Reputation: 24733
You need to set the directory
RewriteEngine on
ErrorDocument 404 http://www.yoursite.com/404.php
If your local then like this
RewriteEngine on
ErrorDocument 404 directory/404.php
Upvotes: 1