9.1. Handling Requests for Missing or Relocated Pages

Problem

You need to guide users through errors and keep them happily browsing your web site, even when things go wrong.

Solution

Missing pages accompanied by cryptic or meaningless error messages can turn visitors away from your site. Use a custom error page, HTML <meta> tag redirects, and web server Redirect directives and mod_rewrite rules to smoothly guide web surfers over rough patches on your site.

Also, make sure that the error messages your visitors encounter while browsing your site are helpful and user oriented. Here's a checklist to follow:

  • State the specific problem and (if at all possible) a solution. If there is no solution for a typical user, it's probably an error the user shouldn't see in the first place.

  • Keep the message brief, but include advice for avoiding the problem in the future.

  • Use a basic, straightforward design. The error message should be the most prominent, if not the only, element on the page.

  • Use friendly language and avoid strident language (including exclamation points) or "techy" words.

Discussion

An outdated bookmark, an old offsite link, or even a typo may lead web surfers to request a page that's not on your site. The HTTP error code for a missing page is 404, so in webmaster parlance a 404 page is the page visitors see when the requested page is not found.

Tip

A good web hosting provider will provide you with easy-to-read traffic statistics, where you can actively monitor bad links people are trying ...

Get Web Site Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.