29 January 2012

.Htaccess Power: The Custom Error Page

I heard about a friend who was having trouble with dead links that came up in Google Searches.  Here's a solution: you can create a custom 404 error page that brings people to your site and lands them safely into a zone that says "sorry! that page isn't there, but you're on the right track." 

It's called .htaccess and probably the tricky part is naming the file.  Most files are called filename.txt where ".txt" is a filetype and "filename" is the name of the file.  But for this particular file, the filename simply doesn't exist, and the filetype is .htaccess (go figure!).  The best way to create one is to open up the simplest text editor you can find.  Then add this one simple line of text:  

ErrorDocument 404 /errorpage.htm

Now, save the file in the main directory folder of your website.  Rename the file so that it has no name, but contains the lengthy extension ".htaccess" and then upload it onto your server.  

Write a webpage called errorpage.htm (or anything you want; I call mine 'error.htm' but you can modify that in the .htaccess file).  Then, upload that page to your server.  Now whenever anyone stumbles upon a dead link, it will appear as this custom page.  You can even create a custom google search tool to allow the person to keep searching for a term only on your website, or route it back to your main index page.  

Hopefully it solves the problem!  There is much more you can do with .Htaccess, which is really powerful in modifying your server, which statistically probably runs on Apache if you host your site with any standard company.  More .htaccess tricks will be announced in the future, here on Stereomedia!

L.S. Aristotle ((o))

No comments:

Post a Comment