Web Helpdesk - Custom Error Messages
create custom error messages for your website, just create a file named ".htaccess"
in any subdirectory from which you serve web pages. These custom error messages
will apply to that directory and all subdirectories beneath it.
is an example .htaccess file:
404 "Sorry, that file was not found."
the user requests a document to which access is not allowed (a 403 error),
they will be shown the document "/errors/restricted.html"
is just as if they requested
except the URL they see will be the one they entered, for example, "http://www.servername.com/.htaccess"
this to work, the filename given MUST be absolute, for example,
and not "errors/restricted.html",
as this is actually the trailing part of the URL to be effectively shown. If
the "/" is omitted, instead the error would be shown as text, as in the next
the user requests a document that does not exist (a 404 error), they will be
simply shown the text "Sorry,
that file was not found."
Note the lack of the trailing quotation mark; this is intentional, as it otherwise
will be displayed.
the user requests a document that causes a server error (a 500 error), such
as a malfunctioning CGI program, they will be redirected to the URL "http://www.dezines.com/errors/server_error.html".
This is different from the first example, in that here the browser is actually
told to fetch this new document at the given URL, instead of the contents of
that URL simply being sent along to the browser with no perceived redirection
as in the first example.
error can be redirected to a CGI script instead of a .html file, which could
provide detailed information about the error, and also log any pertinent information
in a MUCH more detailed manner than Apache does by default.
DO NOT redirect 500 errors to a .CGI script, because if .CGI happens to not
be functioning, an endless loop will be created!
that any error number can be given any of the types of redirection responses
as shown above, but generally the most useful is the first form where the .html
file or .cgi program is simply shown in place of the default error message.
careful not to restrict access to the /errors directory (or whatever directory
you place the error messages in), so that weird things don't happen.
revised November 19, 1999