One use of the .htaccess file is to redirect users to a custom error page depending on the specific web server error they encounter. By using a custom error page, you can present them with a list of your site's top articles, a sitemap with links to the various areas of your site, and it can include your site's navigation system. It can also feature a FAQ, so folks who are looking for information on your site, but can't find it, are able to narrow down the location of that information on your site without leaving, going back to the search engine, and more than likely not returning to your site.
It's not difficult to use the .htaccess file to redirect users to a custom error page--but to do it you'll need to know the proper error code. The most common ones you'll use are:
- 400 - Bad request
- 401 - Authorization Required
- 403 - Forbidden
- 404 - File Not Found
- 500 - Internal Server Error
ErrorDocument 404 /filenotfound.htmlIf you wanted to redirect users for another error, such as 500, Internal Server Error, you would do it like this (and so on):
ErrorDocument 500 /servererror.htmlThen you'd just save the .htaccess file (remembering to check that it is saved just like that, without some additional extension), and upload it to your web host's root directory (or whatever directory you are wanting to use it in).