Using .htaccess files to customise error messagesAt Precedence Internet, we use a webserver called Apache. This is most widely used webserver in the world. Apache is highly configurable and it is possible for some options to be set by the end user. This is performed by creating text file called .htaccess in your directories.
A brief guide is given below, but this is no substitute for having read the Apache documentation.
Setting up custom error pagesIf someone accesses a page on your site that does not exist, then they will be sent a error message by the webserver. This will consist of an error code (404 for file not found), plus a small HTML page that will usually be displayed by the browser to the user. The page returned can be customised, so that the error message is more friendly. It could also redirect the visitor to your home page or site map. (Apache can also be set up so that the webbrowser is redirected to a different page which could even be on a different server. This is generally a bad idea, as the original 404 error will never be returned and so search engines may not realise they have visited a non-existent page).
To set up a customised error page for 404 error messages, simply create a .htaccess with the following line:
ErrorDocument 404 /404redirect.htmlThis will output the contents of 404redirect.html in the root of your website when a "404 file not found" error occurs.
You may also create custom error pages for other errors. Please see the Apache documentation for more details.