Custom Error Pages
Have you ever tried to visit a web page and gotten a plain white page informing you that the page you were looking for wasn't found? Or that the server received a bad request? These are called 'error pages'.
Here are some of the more common error pages that can be replaced with ones of your choosing:
- 400 Bad Request
- 401 Authorization Required
- 403 Forbidden
- 404 Not Found
To use your own error document you need to add a line like the following to your htaccess file:
ErrorDocument 404 /errorspagesdirectory/notfound.html
The text in green would be a directory where the custom error page is located. It can be named anything you like. The purple text is the name of the page that is to be called by the error and again this can be named anything you like, but is best named something that will easily identify it as the correct error page.
It is not necessary to put your error documents into a special directory. They can be placed in the default html directory in which case the resulting code would be
ErrorDocument 404 /notfound.html
It is just better practice to put all your error pages into their own directory because then you can exclude that directory in your robots text file. In either instance do not remove the beginning '/' as your server will not be able to find it otherwise.
So what would you put on your 'notfound.html' file? Possibly links to your site map to help your visitors find what it is they're looking for, or a link to your homepage. At the least you may want to brand it with the same look and feel as the rest of your site.
To create an htaccess file just create a text document with the above code on it. To add other error documents just follow the same format putting each additional directive on it's own line like this:
ErrorDocument 401 /errorspagesdirectory/authrequired.html
ErrorDocument 403 /errorspagesdirectory/forbidden.html
ErrorDocument 404 /errorspagesdirectory/notfound.html
and so on...
Now save this text document with the name (dot)htaccess being sure to include a period (dot) before the h and ftp it up to your server's html or public directory.
If you already have an htaccess file on your server, just add these lines to it. Remember to put each directive on it's own line and you're good to go.
Now get creative and save your site's visitors from error document boredom.