Recipe 9.3 Customized Error Messages

Problem

You want to display a customized error message, rather than the default Apache error page.

Solution

Use the ErrorDocument directive in httpd.conf:

ErrorDocument 405 /errors/notallowed.html

Discussion

The ErrorDocument directive allows you to create your own error pages to be displayed when particular error conditions occur. In the previous example, in the event of a 405 status code (Method Not Allowed), the specified URL is displayed for the user, rather than the default Apache error page.

The page can be customized to look like the rest of your web site. When an error document looks significantly different from the rest of the site, this can leave the user feeling disoriented, or she may feel as if she has left the site that she is currently on.

See Also

  • http://httpd.apache.org/docs/mod/core.html#errordocument



Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net