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.
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
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".
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.
The above link is incomplete which triggers a 404 response on my
server - and the custom error page.
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">
don't want search engines spidering the page - it has been known to cause
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
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
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.
paid cash taking online surveys - free to join online
In Loving Memory - Mignon Ann Bloch
copyright (c) 1999-2011 Taming the Beast Adelaide - South Australia