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.htmlDiscussion
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 think she has left the site that she was on.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access