returning a true 404

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi Folk

My .htaccess file reads:

ErrorDocument 400 /404.php
ErrorDocument 401 /404.php
ErrorDocument 403 /404.php
ErrorDocument 404 /404.php

This means if someone types in the wrong address (e.g. ) then they are automatically redirected to  

Now, I would like this to continue, but also return a true 404 (as required  
by Google), can you tell me how to do this?

Can you confirm that just placing the following at the top of my script  

 header("HTTP/1.0 404 Not Found");

even if I use ob_start and ob_flush?

Thank you

- Nicolaas  

Re: returning a true 404

windandwaves wrote:

Quoted text here. Click to load it

What happened to 400.php, 401.php and 403.php?

Quoted text here. Click to load it


As long the header() statement is the first thing in your script.

Or you could just use ordinary HTML documents for your error pages. The  
server will take care of the 404 headers for you.

philronan [@] blueyonder [dot] co [dot] uk

Re: returning a true 404

I think the guy was wanting to override 400, 401 and 403 with new 404
replies. I'm not sure why but I think that was the intention.

And there's an easy way to test it. Just code it like that and use
either a telnet style program to submit and examine the response
headers yourself or use the "web developer toolkit"
( /) and the firefox browser,
and click Information > View response headers after visiting each
40x-style page.

And it's reasonably easy to reproduce 401 and 403 with permissions and
the like. And the 400 can be reproduced with the telnet style method I

Re: returning a true 404

Al wrote:
Quoted text here. Click to load it

Thanks Guys - Awesome.  I think I got it sorted.  I have that developer  
thing on Firefox and it is working superbly now.

Site Timeline