Keeping Visitors Through 404 Errors - Making Your File
(Page 5 of 5 )
Now that all that’s out of the way, here’s how to make your .htaccess file.
1) Open up your favorite text editor.
2) Paste this code into the editor:
ErrorDocument 404
/filename.html
3) Save as htaccess.txt.
4) Upload the file to the Top Root of your directory.
5) Rename the file as ".htaccess".
6) Create and upload the error 404 document filename.html
7) Type in an incorrect file path such as www.YourDomainName.com/does-not-exist.html
8) Revel in your hard work
What Does it All Mean?
The .htaccess file used effectively can be a very powerful tool. It can be used for far more than just creating error404 documents. In this case it simply tells the server that the ErrorDocument 404 is /filename.html rather than the default ErrorDoocument 404. If this command were not in .htaccess or if there was no .htaccess at all then the default 404 error document would be displayed.
The .htaccess file can be used to stop certain user agents from visiting the site e.g. – an annoying spider that won’t obey the robots.txt file. It can be used in conjunction with .htpasswd to password protect a directory as well as many other things.
In Conclusion
Having a custom error 404 document may not seem like a big deal but when you consider that it needs no maintenance, does not cost anything and keeps your potential customers on your site becomes a smart move. By holding on to your customers you are keeping them on your site ready to buy from you, not your competitor. This is a classic example of the phrase “prevention is better than cure.”
The important things to remember are:
- Make sure you have the dot in the .htaccess file.
- Make your error 404 document look like every other page on your site.
- An Error 404 page stops bad and out-of-date links tarnishing your image and keeps customers on your site.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |