How can I modify messages that visitors of my pages get when errors occur?
The World-Wide Web server on Eniac allows users to specify URLs to be displayed in place of default messages when errors (such as "Not found") occur. This is achieved by placing an ErrorDocument directive in the ".htaccess" file. This file is described in greater detail in a separate article.
The directive is specified as follows:
ErrorDocument error_code html_file
- "error_code" is the standard HTTP code that specifies the
error we want to catch. The following are common error codes and their
- 401 Unauthorized
- 403 Forbidden
- 404 Not found
- 500 Server error
- "html_file" should be a valid URL to the error file you want to display when that error_code is encountered. You can specify a relative URL, a full URL, or a string with the text you want to display.
For example, to display the URL
http://www.seas.upenn.edu/~username/mydir/myfile.html whenever a
non-existent file in directory
accessed, put the following into the
ErrorDocument 404 /~username/mydir/myfile.html
For full details on the ErrorDocument directive, see the Apache Documentation.