Home arrow Apache arrow Page 2 - Custom Error Pages with Apache

Creating a custom error page - Apache

Nobody enjoys seeing an error page. It's worse if the error page gives you little or no information to help you find the page you were trying to reach. Fortunately, there are ways to configure Apache so that your visitors need never feel so abandoned. This article explains how to set up custom error pages with Apache.

  1. Custom Error Pages with Apache
  2. Creating a custom error page
  3. Internationalized error pages
  4. Maintaining and updating error pages
By: Dan Wellman
Rating: starstarstarstarstar / 13
April 03, 2006

print this article



Configuring Apache to serve customized error pages is extremely easy; there is a section of the httpd.conf file devoted to this. It takes just one directive per error to achieve.  If you open the conf file and scroll right down to almost the very bottom of section two, youíll see the section you need to edit:


By default, these directives are commented out, but all you need to do is un-comment each directive and then change the path to point to your own error page:

ErrorDocument 404 /errordocs/404error.html

Quite simply, this statement is broken down into the directive name, the error code and the path to the document you wish to use.  You could substitute this last part simply for text enclosed within double-quotes to specify the text to be displayed on the page, but this is hardly an improvement on the default messages themselves.  Also, this path could alternatively be the path to a script.  As you can see, Iíve put my error documents into a separate folder in my siteís directory structure.

So, very quickly and easily then, you can simply create a series of your own error documents, to cater for the most common server error codes and add the required directive to the conf file.  In addition to enhancing the user experience by giving a more pleasant error response, you can also introduce consistency across your site by using CSS to make the pages look like the regular pages of your site.  You should also make sure that the pages fit in with other policies in effect on your site; if you pride yourself on your adherence to the accessibility guidelines, for example, you need to ensure that your site map and a help page are linked to from the error pages and that any other applicable guidelines are satisfied.  This is common sense anyway, and if you want to provide better error handling from a userís perspective, youíll probably want to link to different parts of your site anyway to prevent the error pages from being dead end pages with the user given no choice but to reach for the Back button.

For some different examples of custom error pages, you can view both extremes; at Google for example, the custom error pages simply contain a Google logo and a very brief message.  They arenít overly helpful, but they are consistent with the overall design of the site.  Ebay, on the other hand, provides a very large and highly customized error page, with many links and tons of information.

>>> More Apache Articles          >>> More By Dan Wellman

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Apache Unveils Cassandra 1.2
- Apache on ARM Chips? Dell and Calxeda Help M...
- The Down Side of Open Source Software
- VMware Unveils Serengeti for Apache Hadoop
- SAP Takes Steps to Improve Hadoop Integration
- Looking to Hone Apache Hadoop Skills?
- How to Install Joomla on WAMPP
- Working with XAMPP and Wordpress
- GUI Available for Apache Camel
- Reduce Server Load for Apache and PHP Websit...
- Creating a VAMP (Vista, Apache, MySQL, PHP) ...
- Putting Apache in Jail
- Containing Intrusions in Apache
- Server Limits for Apache Security
- Setting Permissions in Apache

Developer Shed Affiliates


Dev Shed Tutorial Topics: