Friendly People.
Professional Support.
24 hours 7 days a week.
We're here for you.
Custom Error Messages
To get custom error messages on your site, just create a file named ".htaccess" in
any subdirectory from which you serve web pages. The error messages
will apply to that directory and all directories underneath it, and
can be overridden by additional .htaccess files in those subdirectories
if necessary.
Here is an example .htaccess file:
ErrorDocument 403 /errors/restricted.html
ErrorDocument 404 "Sorry, that file was not found.
ErrorDocument 500 http://www.superb.net/errors/server_error.html
In this particular example:
If the user requests a document to which access is not allowed
(a 403 error), they will be shown the document "/errors/restricted.html".
This will be just as if they requested http://www.domainname.com/errors/restricted.html,
except the URL they see will be the one they entered, for example, "http://www.servername.com/.htaccess"
For this to work, the filename given MUST be absolute, for example,
/errors/restricted.html, 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 example.
If 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.
If 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.superb.net/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.
Some pointers:
* Any 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.
* However, DO NOT redirect 500 errors to a .CGI script, because if .CGI
happens to not be functioning, an endless loop will be created!
* Remember 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.
* Be 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.