Custom 404 Error PagesA 404 error page occurs when a visitor requests a page that does not exist. The web server has an error code designated to every possible muck-up that could occur; 404 happens to be the one that means “file not found”. The problem is, 404 error pages tend to look ugly. Often, your web browser will take over and give you its own rendition (which usually tells you even less than the web server’s version!) The solution? Create your own. Any HTML document (or dynamic page, for that matter) can be specified as your 404 error page. You can usually do this with one of two ways:
You will need to check with your web hosting provider that you are able to do one of the above. Either way is fine, although you might like to learn how to htaccess files as a matter of course; they come in handy as you progress down the web development path. When creating your 404 error page, make all file references absolute. That is, when you specify an image, use the full domain name (or path) in the SRC= attribute; when you link to another page, do the same. This is recommended because if a visitor requests a page that exists in a directory, the 404 error page will be loaded as if it resided in that directory, meaning images and links will be broken. To specify the 404 error page using your web host’s control panel, consult their manual, or email tech support. To specify the 404 error page using htaccess, do the following:
The ErrorDocument command takes two parameters; the error number (in this case, “404”) and the filename (in this case, “/404.html”). You can even specify a PHP script if you’d like to do advanced things with your 404 error page, such as show a site map, perform a search, try to guess the correct page, or email you an error report. Custom 404 error pages are essential for a professional website, especially one whose pages often change. When selecting a web hosting company, be sure to check they support this feature.
|
|