Apache
  Home arrow Apache arrow Page 4 - Custom Error Pages with Apache
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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? 
APACHE

Custom Error Pages with Apache
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Dell PowerEdge Servers

    Custom Error Pages with Apache - Maintaining and updating error pages
    (Page 4 of 4 )

    You are now faced with the same problem that we initially set out to fix: bland and generally unhelpful error response documents.  However, the fact that the server-generated page makes use of included html pages means that you have a centralized method of maintaining and updating these error pages to fit in with your site's design, making them much easier to customize and manage.  If you look at one of the include pages in a text editor, you’ll see a special section there that defines some very basic styles.  This is where you can add your own style rules in order to customize the look of the error page.

    The 404 response is probably going to be the most common error result that is going to be seen by visitors to your site.  Sometimes, this is going to be because they’ve misspelled a URL or clicked on a link to a resource that no longer exists, but very often, it can be the result of site reorganization, or pages being moved from one directory to another within your site's internal structure.  Client redirection is extremely easy to configure; you simply use the Redirect directive, the name of the old directory and the URL of where requests to the old directory are redirected to:

    Redirect /olddir/ http://localhost/newdir/

    This will only be effective when there are no longer any pages in the olddir directory however, as any request for a page within that directory will be redirected to the newdir, so a request for www.mysite.co.uk/2005/quarter1.html where 2005 is set in the place of olddir will automatically be redirected to www.mysite.co.uk/2006/quarter1.html when http://mysite.co.uk/2006/ is set as the newdir.  If just an individual page has been moved, you can simply add a directive specifically for the page that has moved:

    Redirect /olddir/movedpage.html
    http://localhost/newdir/movedpage.html

    You can even use the Redirect directive in conjunction with your customized error pages by making use of the status argument, which comes directly after the directive name.  The status can be an error code or one of several keywords.  If, for example, a page has been removed from your site rather than just moved, you can add the following directive to your conf file to let visitors know:

    Redirect 404 /olddir/deletedpage.html

    This will generate the HTTP_GONE.html.var error response when internationalized error messages have been configured.

    Apache has many other directives that can be used to deal with ever more complex redirection issues, but these are beyond the scope of this article.  You’ve seen how easy it is to configure your own set of custom error response pages, and how to enable customized error responses that can be displayed in a variety of languages depending on the preferences of requesting clients.  Additionally, you’ve learned how to redirect browsers when requesting pages that have moved or been removed so you can try to minimize the number of times your custom error pages need to be displayed.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hi,I hope you enjoy learning how to set-up these very simple mechanisms that can...
     

       

    APACHE ARTICLES

    - 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...
    - The Properties of Tapestry Pages

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway