Delivered each Tuesday, TechRepublic’s free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!
When Apache encounters an error, it displays a
designated error message that’s prebuilt into the server. For
example, let’s say that you try to load a page that Apache can’t
find or that doesn’t exist. Apache returns a 404 (page not found)
error and provides a rather drab Web page that indicates the error
(and often the e-mail address of the Webmaster).
Apache draws this information from the data
stored in the httpd.conf configuration file. However, you can spice
things up by creating your own error documents.
Your error documents can be regular HTML, PHP,
or any other Web document that the server supports. For instance,
to create a new error message for a 404 error that better fits your
site, use something like the following:
ErrorDocument 404 /404.php
You can use this globally or inside a
VirtualHost stanza to affect one particular domain.
Of course, you must supply the file; in this
example, it’s 404.php, located at http://www.yoursite.com/404.php.
This file should contain the error message and anything else you
want to specify.
You can also do this for any other error
message type. In addition, you can present custom error messages
without creating a whole page. Here’s an example:
ErrorDocument 500 “The server has encountered a
problem. Please send flowers.”