Custom error page
From Wikipedia, the free encyclopedia
A custom error page is a feature of most Web server software that allows you to replace default error messages with ones you create. The default error messages tend to be fairly generic, and not particularly user-friendly, so making custom messages for a site is recommended.
You can make them look more like the rest of a site, and/or provide better recovery navigation. The Not Found (404) error is the one users are most likely to encounter, so it is the most likely to be customized.
Contents |
[edit] Default 404 error messages
[edit] Custom 404 error message examples
[edit] Creating custom error pages
The instructions below assume you have direct access to a Web server you set up. If your site is hosted by a third party, they may have already provided one or more default error pages. Check your host's documentation.
[edit] Custom error page creation using Apache HTTP Server
If you run a Web server using the Apache HTTP Server software, you can easily specify custom error pages through server configuration files such as httpd.conf or .htaccess. You can specify custom error pages using the ErrorDocument directive. It is used as follows:
# The following line specifies the error page for the '404 Not Found' error ErrorDocument 404 http://yoururl.com/404.htm # The following line specifies the error page for the '403 Forbidden' error ErrorDocument 403 http://yoururl.com/403.htm # The following line specifies the error page for the '401 Unauthorized' error ErrorDocument 401 /401.htm # Or.. # ErrorDocument 401 "The webserver could not authorise you for content access.
This may be put in an .htaccess file, which can be created using a text editor. Everything defined in an .htaccess file will only take effect for the directory it is located in and its child directories.
It is important to note that the 401 error response must be a relative URL, beginning with a forward slash, /, or a comment, beginning with a double quote " due to the following in httpd_core.c :
if (error_number == 401 && line[0] != '/' && line[0] != '"') { /* Ignore it... */ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, cmd->server, "cannot use a full URL in a 401 ErrorDocument " "directive --- ignoring!");
[edit] Custom error page creation using Microsoft IIS
- Use a text editor or an HTML editor to create your custom page on your server
- From your server's desktop, launch the Internet Services Manager (usually located at Start->Programs->Administrative Tools->Internet Services Manager)
- Click the [+] to the left of the server name
- Right-click on "Default Web Server" (or whatever you may have renamed it as), and click on "Properties"
- Click on the Custom Errors tab
- Click on the number of the HTTP Error you want to make the custom message for, then click "Edit Properties"
- Use the Browse button to locate the custom file you created and click OK. Keep clicking OK to dismiss the windows, then close the IIS window
[edit] External links
- ErrorDocument Directive in Apache HTTP Server 2.0 documentation
- Customised 404 Error Pages Improving website usability with customised 404 error pages
- 404 Research Lab Exploring the art of the 404 page
- 404 Research Lab How to use a 404 Error Page