Make Apache ErrorDocument return 404 instead of 301

.htaccess301-redirectapache-2.2errordocumenthttp-status-code-404

In my .htaccess I have

ErrorDocument 404 http://foo.com/404.html

It works, in the sense that I recover from any file not found error and show the 404 page instead, but the way it works is to redirect the erroneous URI using a 301 to my 404.html page.

This is bad because search engines and crawlers will not end up seeing a 404 code, rather a 301 code and will not purge deleted pages from their indices.

Can I make Apache serve up the contents of this 404 page upon file not found errors, yet still return a 404 code instead of the 301?

Best Answer

You should try to use absolute or relative path and not an URL

My apache2.conf :

ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 500 /error/500.html
Related Topic