Custom 404, 410 (Page Gone) and Error Document

There's a difference between a 404 and a 410 when a page is navigated to and isn't there:

  • 404 Document Not Found
    This simply means the page hasn't been found. There may be a mis-spelling, the page may be temporarily missing or it may have been moved without being redirected. Spiders will come back and look for the page again, in case the page comes back, and it's been my experience that they'll re-include it in the index once it's found again.

  • 410 Document Gone
    The means that the page has been deliberately and permanently removed.

404 is the default when a page is gone when an attempt is made to access it, and is what will normally be returned. To have a 410 returned by the server when a page is removed, a simple entry in .htaccess will return that specific error code. The format is:

Redirect gone removedfile.html
or
Redirect gone /removedfile/
or
Redirect gone /directory/removedfile.html

Custom 404 Error Document (or Custom Error Document for 410)

To create a custom error document for either a 410 or a 404, in whichever HTML program or text editor you generally use, create a page that you'd like visitors to see when they try to access a page on your that's missing, instead of whatever it is that the server will return. Place this page in the root directory of your site and give it whatever name you choose.

Then, placing the following line(s) in .htaccess, either one or both, will cause the page to show that you've created specifically for the purpose, when the error is encountered. Different documents can be created for each, or the same one can be used.

ErrorDocument 410 gone-forever.html
ErrorDocument 404 not-found.html

It's a very good idea to put those as the last entries in .htaccess so that they can easily be kept track of and added to in time, if necessary.

 


Web Design Topics

spacer_468x60