Monday, March 26, 2012

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 moons ago, I  noticed around 1% of all requests from my site will return 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

- During that time a couple of search engine spiders had crawled through 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 reflect the database entries, pointing to the wrong filename, visitor clicks on the result - 404.... aaaaaaaaargh!
404 errors may also be caused through a malformed browser request (user error - wrong URL typed into address bar)

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:

http://www.tamingthebeast.net/aaaargh
The above link is incomplete which triggers a 404 response on my server.

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:
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
You don't want search engines spidering the page - it has been known to cause problems.

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 settings to control who can access the contents of a specific directory and how much access they have.  It can also be used to create a "URL Redirect".
If you have a FrontPage based web, be especially careful, as the .htaccess file contains other settings as well.
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 http://site.com/folder/404.htm
ErrorDocument 403 http://site.com/folder/403.htm
ErrorDocument 401 http://site.com/folder/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.

No comments:

Post a Comment