.... Internet marketing resources, ecommerce web site design tutorials
  Taming the Beast - quality web marketing and ecommerce development services .... .


Return to web marketing and ecommerce articles index

Custom error pages - beating 404 errors and keeping visitors

Create custom error pages, help keep your visitors and increase your sales!

HTTP 404 - File not found is a browser error message that we've all grown to know and hate after clicking on a link. 

On reviewing my server logs many, many moons ago, I  noticed around 1% of all requests from my site were returning this HTTP error code. 

One of the reasons for it was a stupid mistake. I wasn't happy with the naming of a couple of my files, so I renamed them without considering the consequences. 

The files had been on my site for short time; minutes actually - but during that time Google's spider had indexed the pages. A search engine spider  is a software program that scours web sites for content and returns the results to a search engine database. The search engine interface feeds off this to return listings to searchers when they have entered their search criteria.

Need to learn about  search engine ranking and optimization strategies or want to monitor the SEO health of your web sites (and those of your competitors)? One of the most comprehensive set of online search engine optimization tools around -  SEOMOZ.

Since I changed the names of the files after the spider went through and had not used a 301 redirect, the pages in their original state no longer "existed".

The search engine query results showed the wrong filename, visitor clicks on the result - 404.... aaaaaaaaargh! These days this kind of thing isn't so prevalent as search engines are quick to dump results that end in a 404 error being generated.

404 errors may also be caused through a malformed browser request (user error - wrong URL typed into address bar), or a broken link from another web site.

A "vanilla" 404 error page is very bland - it does nothing to retain the visitor, so they are likely to just click away.

You can help prevent 404 errors scaring visitors away quite easily - dependent upon your hosting service set up. Instead of a visitor being directed to those rather horrible "file not found" pages, you can create custom error pages. Here is an example:


The above link is incomplete which triggers a 404 response on my server - and the custom error page.

By implementing custom error pages, you have a good chance of retaining the visitor, especially if you include the standard navigation buttons. It also acts as a means of apologizing to the visitor for the inconvenience. More retained visitors can equal more sales.

It isn't just 404 error messages that you can apply this to. There are a number of error code returns that you could customize, all with the goal of alleviating visitor stress and encouraging them to further explore your site. View a listing of http error codes.

Creating custom error pages:

You may want to check with your hosting service first before creating custom error pages as certain hosting configurations may not allow you to create custom error pages. For this exercise, your host needs to support .htaccess files.

1. Create your custom error page

First design and publish the error pages to your server.  You'll only really need to design a couple for the more common errors, for file not found (404) or unauthorized/forbidden (403, 401). Your custom error pages should have a brief summary of what went wrong and an encouragement for the visitor to try again or explore a different area of the site. The best custom error pages are those that match the site's other pages in navigation and layout.

Note: I also suggest adding the following line between the <head> and </head> tags:


You don't want search engines spidering the page - it has been known to cause problems.

When publishing, for simplicity's sake, just put them directly under your home directory. This can get around some issues you may otherwise experience depending on your server setup.

2. Open/create your .htaccess file

After publishing the pages, you'll need to edit the .htaccess file in the root directory of your server based web. Use the Edit utility (set to ASCII transfer mode) in your FTP program  to view the file or a text editor such as Notepad.

The .htaccess file contains a number of instructions to (among other things) control who can access the contents of a specific directory and how much access they have. Be careful not to mess with any existing instructions in that file.

If you don't find a .htaccess file, you can create your own, but once again, check with your hosting service first for guidelines. Be sure to use a plain text editor and name the file ".htaccess" (notice the "." preceding the file name).

3. Edit your .htaccess file

Add the following lines to the end of the file (examples provided as a guideline - alter path and file names to point towards your error pages)

ErrorDocument 404 /404.htm
ErrorDocument 403 /403.htm
ErrorDocument 401 /401.htm 

Upload the .htacess file back to the root of your web in ASCII mode and you should be good to go. Try it out by typing in a non existent URL on your site.

Custom error pages are simple to create, help you to increase your site's traffic by retaining wayward visitors and also encourage better visitor/customer relations.

Important note re: 'soft' 404's

In some tutorials, and even this one when it was originally published many years ago, it was often advised to edit .htaccess like so:

ErrorDocument 404 http://site.com/404.htm

Note the "http://site.com/" prefix to the /404.htm. This is called an "absolute" path. The /404.htm on its own is called a "relative" path.

The reason I advise using a relative path nowadays is if you use an absolute path, this may still work in that the custom error page will display; but it will return the wrong server response code. The response code returned will likely be 302 (moved temporarily) rather than 404 (file not found).

An incorrect response code *may* cause you some search engine related headaches; so play it safe and specify the relative path to your custom error page.

Further note on renaming files

While a custom error page acts as a good backup to try and keep visitors on your site for more random errors such as malformed browser requests; there is a better method to use if you must rename files - a 301 redirect. This will seamlessly take your visitor to the renamed page. More importantly, it's search engine friendly, so it can help maintain the rankings you had for the old page. Learn more about 301 redirects.

Michael Bloch
Taming the Beast
Tutorials, web content, tools and software.
Web Marketing, Internet Development & Ecommerce Resources

Copyright information.... This article is free for reproduction but must be reproduced in its entirety along with live links & this copyright statement must be included. Visit http://www.tamingthebeast.net  for free Internet marketing and web development articles, tutorials and tools! Subscribe for free to our popular ecommerce/web design ezine!

Click here to view article index 

Online meeting & webinar software review
Powerful, easy to use collaboration tools that can help improve your marketing sales and training efforts. Learn more about these services in this review & try a free trial!

The best shopping cart software
Our reviews of some of the best shopping carts around - free ecommerce solutions  through to premium services offering affiliate programs, marketing modules & online soft goods delivery.  Shopping cart software guide 

Autoresponder software/mailing list manager
 Read our beginners guide and reviews of all-in-one autoresponder & email marketing software solutions.

Credit card transaction fraud screening!  Effective fraud screening is an essential part of running an online businesses. Fraud transactions cost you money and can threaten your merchant account. Pick up a stack of transaction screening tips in this free guide! 

Need some advice/tools for writing/creating a web design, development or marketing proposal?






Get paid cash taking online surveys - free to join online 
survey companies that will pay you cash for your opinion!

In Loving Memory - Mignon Ann Bloch

copyright (c) 1999-2011  Taming the Beast  Adelaide - South Australia 

Profile - Contact - Privacy - Consultants Portfolio 

Search Site - Terms of Service - Social/environmental