ErrorDocument in .htaccess Returns 302 Response

October 15, 2007

Just thought I would help out anybody who has this same problem. When using a custom error page to hand 404 errors, you need to make sure you use the local path to the script and not a full URL, otherwise the server needs to use a redirect to get to the page. This will cause a message from Google Webmaster Tools such as "We've detected that your server returns a status of 200 (found successfully) for pages that don't exist. "

So, this line in your .htaccess is the WRONG way:

ErrorDocument 404 http://www.micahcarrick.com/404.php

And this would be correct:

ErrorDocument 404 /404.php
This is easy to test for if you have curl installed on your system using:
curl --header http://www.micahcarrick.com/this-doesnt-exist.html
The right way returns 404, the wrong way returns 302.
Categories: Web Development

2 Comments about "ErrorDocument in .htaccess Returns 302 Response"

Tom
April 12, 2010 at 01:03 AM
Thanks you for this, I was having real trouble figuring why my 403 forbidden page was returning a "302 Found" server header response. Turns out it was the full URL :).
Piutx!
December 17, 2007 at 08:10 AM
Thanks!

Leave a Comment about "ErrorDocument in .htaccess Returns 302 Response"

Your Name:
(Required)
Website URL:
(Optional)
Comment:
(No HTML. Newlines and URLs okay.)
Enter CAPTCHA:
 
 
 
 
Share