404 works with nonexistant.html, but not .php

Hi guys,

I’m having a problem with my ErrorDocument at site root level as follows:

http://www.digitalvibe.co.uk/nonexistantpage.html - produces the correct 404 redirect as teh page doesn’t exist

where as…
http://www.digitalvibe.co.uk/nonexistantpage.php - produces an ugly 404 error, not the 404 page i have defined in my .htaccess.

The only difference being the .php extension rather than .html

Can anyone shed any light on this please? My .htaccess file is included below.

All of the lines are backed up by ln shell commands, eg:

ln worker.php web-site-design.htaccess (in site root):

ForceType application/x-httpd-php

ForceType application/x-httpd-php

ForceType application/x-httpd-php

ForceType application/x-httpd-php

ForceType application/x-httpd-php

ForceType application/x-httpd-php

ForceType application/x-httpd-php

ErrorDocument 403 http://www.digitalvibe.co.uk/errors/403.html
ErrorDocument 404 http://www.digitalvibe.co.uk/errors/404.html
ErrorDocument 500 http://www.digitalvibe.co.uk/errors/500.html
Options -Indexes

[/code]There’s a final carriage return in the file, but the “pre” markup command omits it.

Thanks in advance,

That is a (documented) side-effect of running PHP-CGI. :wink:

Your “not found” is displayed with other “non-php” files, not just an .html file (for instance, http://www.digitalvibe.co.uk/nada); it’s only the php filetype that is creating the problem, because when php is running as cgi “no input is specified” (to the php-cgi) if the called for .php file is not found.

If you read carefully through the information on the page linked above, you will see that user “n74” has posted a “work-around” for the problem (on 2004-11-11 02:31:28):

[quote]"Good news everybody… I think I solved the “No input file specified”, no custom 404 pages for .php files problem:

in /home/user/yourdomain/.htaccess

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

Simply change either /404.html to anything you’d like…
I hope this helps. (oh and change .php to .phtml or .php3 if you need to)"[/quote]
There is other information regarding variations of that “fix” in the other comments, so you should read through those to see what “tweaks” if any may be needed for your situation. :slight_smile:


rlparker, thank you so much for the information and pointer! I really appreciate your reply instead of “RTFM”, considering the topic is documented already!

I’ve been faffing with my .htaccess and scratching my head for the last few hours thinking i’d done something wrong… rather than NOT doing something i need to do!

I’ll have a proper read of the link you posted to see which is the best tweak for me… i must admit, I didn’t even know about the existence of the KB! bookmarked

Thanks again, you’ve been a great help!


No problem, Karl! You are most welcome, and I hope you find information there that will help with your problem.

You are not alone in not knowing about the “old” KB - it was phased out a few years ago in favor of the wiki (which is actually a “good thing™”), and all of the “original article” info was moved there.

Unfortunately, not all of the “user comments” successfully made the move, so it is still helpful that there is that old “archive” laying about, as there is occasionally some “gold” buried there. :wink:

Generally, the wiki is the better resource, as there is quite a bit of data in the old KB that no longer applies to the DreamHost of today, but there is some “hidden treasure” lurking in those old user comments from years ago that is still relevant for some problems you could encounter today.


Looks like it’s all working fine now, yay! I was just able to lift the example from the KB comments and change the file path - i needed no more tweaking.

The only problem is that my 404 reporter code already has 2 Googlebot attempts now for the example links I posted above! Nooo! I would mind if they were indexing the domain itself(http://www.digitalvibe.co.uk), but not crawling deliberately fake addresses, heh.

I’ve used the DH wiki, but I often find the search a bit hit & miss at times. I’m never been able to feel completely comfortable using wikis!

Well i’ve been with DH for 2 years now, and this is the first experience i’ve had of community support, and I must say that i’m well impressed :slight_smile:

Thanks again,

Hey, living life focusing on striving for “Google Goodness” can be very frustrating! :wink:

I agree that searching the wiki can be a little frustrating… you can “get there” but it often takes a couple of attempts. BTW, I added a page on that whole “Custom error pages with PHP-CGI” issue you were having to the wiki (just distilled the old comments from the KB). It really should be in there, as others are likely to have a similar question.

I’m glad you found your first trip to the forums to be a rewarding experience. Welcome, and jump in yourself to contribute when you can. :slight_smile: