Implementing custom error pages for a website

One of the features used in my website is custom error pages, which allow errors to be handled using a format that matches other documents on the site.

Apache users can configure custom error messages using .htaccess. Once pages have been created for an error message, include a directive in the .htaccess file as follows:

ErrorDocument error-code document

For example, ErrorDocument 404 /errors/404-notfound.shtml will redirect any page not found (HTTP error 404) errors to display the /errors/404-notfound.shtml document.

Full details for Apache users may be found in the Apache core features documentation.

Microsoft Internet Information Server (IIS) users can find information on configuring custom error messages in the IIS 6.0 Operations Guide.

RFC 2616 details all of all HTTP status (including error) codes.

Comments

3 responses to “Implementing custom error pages for a website”

  1. […] IP ranges, I’m more likely to reject x-moz: prefetch requests and, instead of sending back a custom HTTP error page, I’ll probably refer to no web accelerator (unnecessary proxying considered […]

  2. Reed avatar
    Reed

    Google has a new 404 tool (http://www.google.com/support/webmasters/bin/answer.py?answer=93644) it generates on your 404 pages with javascript (like adsense) links that they may be interested in from google index within your domain. Then you can check your 404 page http error code is correct with tool like this – http://www.httpviewer.net/

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.