On Apache servers, this can be done by editing a file called ".htaccess"
on the www root directory. Add the following
line.
ErrorDocument protocolCode fileHandler
Where
- protocolCode is one of the protocol error codes
- fileHandler is the file that you want to display
whenever that error occurs
For this to work, the web server must have been configured to
allow ErrorDocument override. Contact the ISP if you're not
sure.
For example:
ErrorDocument 401 /badreq.html
will cause the browser to display the file badreq.html when a
document is not found
ErrorDocument 403 /errDoc/forbidden.html
will cause the browser to display the file forbidden.html if an
user tries to access a forbidden document. Notice that the
fileHandler can be located anywhere, but it must be referenced
with absolute path (relative to the root directory of the www).
ErrorDocument 404 /cgi-bin/nf.cgi
will cause the browser to execute the script nf.cgi if an user
failed to enter a password protected directory.
As can be seen above, you can change almost all of the error
codes handler. If you do not specify a handler, then the
default will be used. (The default might have been set by
your server administrator; if not, then you will get the standard ugly
message such as shown on the screenshots above.)
See this examples:
ErrorDocument 403
ErrorDocument 404
Reference
The
World Wide Web Consortium
|