Filed under:

How to create custom error pages ...




To use your own custom error pages you must first create the html page(s) you want displayed ... for simplicity we recommend that they are named the same as the error code for which they are to be displayed. i.e. 404.htm for the page to be displayed on a 404 error. Some common error codes are ...

  • 401 - Authorization Required.
    This document is displayed when a visitor supplies an incorrect username/password to a restricted area of your web site.
  • 403 - Forbidden.
    This document is displayed when a visitor tries to access an area of your web site which you have specifically forbidden access.
  • 404 - File Not Found.
    This document is displayed when a visitor requests a specific page and the page is no longer available (renamed or deleted).
  • 500 - Internal Server Error.
    This document is displayed when an error occurs while running a script.

Your website is hosted on an Apache based webserver. For a complete description of the ErrorDocument directive see http://www.apache.org

To activate your own error pages, you must ...

  1. Download the file called .htaccess from the root directory of your web site (if there is one already)
    It MUST BE downloaded in ASCII mode.
    Before making any changes make a backup copy - if this file is not correct your site may become unavailable.
  2. Using a text editor/Notepad [NEVER USE WORD/WORDPAD] add the following line:
    ErrorDocument ErrorDocumentNumber FullUrl
    where ErrorDocumentNumber is the Apache number e.g. 404 and FullUrl is the full http location of your error page.
    e.g. ErrorDocument 404 http://www.yourdomain.co.uk/404.htm
  3. Save your .htaccess file and the upload it to the root of your website, again using ASCII mode.
  4. Test it. First by going to your home page. Then go to a page that will force the error page to be displayed.
    For example, assuming a page called test404.html does not exist in your site, enter into your browser address bar http://(yourdomainname)/test404.htm
    Your new 404 error page will be displayed.

If after uploading your new .htaccess file, your web site becomes unavailable, restore the .htaccess file from your backup. You did make a backup - didn't you ? then start again from [2].

Microsoft assumes you would rather see their 404 message instead of the 404 message designed by the web site owner. To change this, in Internet Explorer choose Tools > Internet Options, Advanced, Browsing - uncheck 'Show friendly HTTP error messages'

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read

Language: