Home > AAPT Information Library > Hosting Documentation > ErrorDocument
Apache (the web server software that powers your Unix VWS) allows you to customise the error messages seen by your visitors. By default, however, simple web pages are returned, so a user who tries to access a non-existant page might see:
Displayed in browser |
Actual HTML |
Not FoundThe requested URL /foo/bar.html was not found on this server. |
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>404 Not Found</TITLE> </HEAD><BODY> <H1>Not Found</H1> The requested URL /foo/bar.html was not found on this server.<P> </BODY></HTML> |
Each error type has a status code, like 404 for "Not Found" or 401 for "Unauthorised". For each type of error, you can customise the page the gets sent back to the browser. To do this, you use the Apache directive called ErrorDocument. It should be placed in a file called .htaccess in your htdocs directory. (If you don't have a .htaccess file, you can create one.) Usage for ErrorDocument is:
ErrorDocument code file|URL|string
The first argument, code, is an HTTP status code like 404 or 401. The second argument can be a filename, a URL, or a string enclosed in quotes.
ErrorDocument 404 /errors/notfound.html ErrorDocument 401 http://www.example.com/cgi-bin/register.cgi ErrorDocument 500 "An error has occurred - please try agin later."
| Copyright © AAPT Limited |
|