By default, most Web servers return a simple "
404 Not Found" error message when they get a request for a URL that they don't have. This error message violates the three basic guidelines for error messages. All error messages must be:
- written in plain language that is easy to understand for non-technical users and that does not imply that the mistake is the user's fault
- precise in specifying exactly what was done wrong (that is, not be generic or vague)
- constructive in suggesting steps the user can take to correct the problem
In terms of the "URL not found" error message, it would be better to explain to the user why the URL could not be found. It would be even better to list the most common mistakes in accessing files on the given site: for example, users often request URLs ending in
.htm for sites that consistently use
.html for all pages (or they use
.html when all pages end in
.htm ). For any given site, it is recommended to have consistent naming conventions and list these conventions on a custom error message page.
Even better: provide a constructive error message by having the server perform a spelling check on any erroneous URLs to see if they are a close match for valid URLs. Even though Apache supports this feature, the necessary code (mod_speling) is unfortunately not compiled in by default, so it is necessary for the webmaster to recompile the server to improve error handling.
Tobias Ratschiller reports that it reduced the number of 404-errors by at least 40% when spelling check for failed URLs was added to a site with hotel homepages.
If your Web server supports customized 404 error pages, then the recommended actions are:
- design a customized 404 error page for your site - it can't help but be better than the standard error message
- start with a simple and slightly apologetic statement that the requested URL could not be found on your site
- add a listing of the most common mistakes in specifying URLs (you can write this list after studying your log files to see what errors are made the most)
- if possible, perform a spelling check on the requested URL and list any close matches (made into hyperlinks so that the user can go directly to the desired page by a single click)
- finally, the error page should have a search field linked to the site's search engine: even when users can't guess the current URL, they may be able to specify a query to locate the desired information
I thank Tobias Ratschiller (firstname.lastname@example.org), who is a new media consultant in Italy, for suggesting that improved 404 handling can alleviate linkrot problems.
Update added April 1999: Internet Explorer 5.0 apparently assumes that anything shorter than 512 bytes is a poorly written server error message and replaces it with its own text. The IE5 error message is admittedly more usable than the standard error message, but often less appropriate than a customized error message that can provide constructive hints for getting the desired page on the specific site. Thus, even though usually I advocate short text, it will be necessary to make any customized 404 message more than 512 characters long to have it displayed by IE5.