How To: Simple Error Pages With .htaccess
HTTP error pages are more important than some may think. If you have a visitor or a customer to your site and they reach an error, you want to display a message and give them alternatives to find the content they are looking for. Most graphical control panels from hosting companies give you the option to easily setup error pages, but if you are in a situation where you need to create error pages on your own .htaccess is the way to go. In two easy steps you can have error pages up and running.
Step 1: Create your .htaccess File
Create a file called .htaccess and put the following contents in this file. Then place this file in the root “/” directory of your web server, where your web content goes.
[ftf]
ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
[/ftf]
Step 2: Create Error Pages
Now you want to create the above HTML files with their respective names. In these files you can put any sort of message to your visitors. It is a standard HTML file, no special rules apply.
Done!
Told you it was easy. Not you should be able to test it out by going to a page that does not exist on your website, and getting to the appropriate page above.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

























Comments
No comments yet.
Sorry, the comment form is closed at this time.