Apache
  Home arrow Apache arrow Page 2 - Custom Error Pages with Apache
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
APACHE

Custom Error Pages with Apache
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 11
    2006-04-03


    Table of Contents:
  • Custom Error Pages with Apache
  • Creating a custom error page
  • Internationalized error pages
  • Maintaining and updating error pages

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Custom Error Pages with Apache - Creating a custom error page
    ( Page 2 of 4 )

    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
     

       

    APACHE ARTICLES

    - Creating a VAMP (Vista, Apache, MySQL, PHP) ...
    - Putting Apache in Jail
    - Containing Intrusions in Apache
    - Server Limits for Apache Security
    - Setting Permissions in Apache
    - Installing Apache
    - Apache Installation and Configuration
    - Apache Tapestry and Custom Components: DateI...
    - Tapestry and AJAX: Autocompleter and InlineE...
    - PropertySelection and IPropertySelectionMode...
    - The DatePicker and Shell Components of Apach...
    - Apache Tapestry: ASO and More Components
    - Apache Tapestry and DirectLink, IoC and DI
    - Making a CelebrityCollector with Apache Tape...
    - Apache Tapestry and Listener Methods, Condit...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek