Home arrow Apache arrow Custom Error Pages with Apache

Custom Error Pages with 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



Apache, as you know, is the most popular web server in use today. Since it is historically easily installed, easily configured and very flexible, itís not difficult to see why.  Many of the easily configured options that are possible with Apache, however, are not exploited to their fullest.  Most of Apache's various server configuration options are switched off by default, and although this makes the server much more secure, it also means that a default installation will not take advantage of many of the things that make Apache what it is.  The httpd.conf file, Apacheís main configuration file, actually says in section 2: "Note that from this point forward you must specifically allow particular features to be enabledÖ"

Error messages are certainly a pertinent example of this; Apache can very quickly and easily be set to display almost anything you want, from simple text (yuk) to custom HTML pages or even PHP and Perl scripts.  Itís all too common, however, to see the very plain, default error messages that are displayed when the server encounters the standard set of errors, such as the all too familiar 404 or "Page not found" error response.  These default pages are ugly, sometimes confusing, very often nothing like the rest of site and almost always detrimental to user experience.  Thereís no excuse for sticking with these default error pages, especially when it really is so very easy to use alternatives of your own devising.

Anyone reading this is going to be using Apache, if not in production, then at the very least as a development tool, but the browser you use for testing can also have an impact on your work.  With the default set up of Apache, if you use Mozilla to try to access a page that does not exist you will see the default Apache server 404 error page, but if you use MS IE5+ you wonít see the default Apache 404. Instead, youíll see the default Internet Explorer 404 page.  This is Microsoftís so called "friendly error message" which overrides the Apache defaults.  The reason for this is that the Apache defaults are all less than 512 bytes. 

This overriding featuring of IE can be switched off using the "show friendly error messages" setting in the Tools -> Internet options dialogue, although by default it is set to on, so bear in mind that most people will have this set if they are using IE (which a large number of Internet users are).  This isnít overly important but should be taken into consideration; to overcome this setting automatically, you need to ensure that the pages you wish to use as error pages are larger than 512 bytes.  This isnít too difficult to achieve, but if you arenít seeing what you should be seeing when creating and testing your error documents, it would be wise to check the file size of your error pages or disable this feature in IE.

>>> 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: