What are custom Error Code pages?
Instead of seeing the default error message, you can create your own error pages by adding special command lines to a .htaccess (pronounced dot h t access) file.
This file typically lives in the /public_html/ directory in your account. Or if you have add-on domains, it lives in /public_html/{add-on domain}/.
You may already have one in there. If that is the case, then you can just add these lines to it. Otherwise, you canjust create a new, empty, .htaccess file to add these lines to it.
The format for an ErrorDocument statement in a .htaccess file follows:
ErrorDocument CODE URL
The CODE refers to the error code you wish to redirect (403, 404, 500, etc) and URL refers to the location of the file you would like displayed.
The URL can either be a URL-Path (e.g. /errors/404.html) or a full URL (e.g. http://www.example.com/404.html).
For an addon domain or subdomain the error page path must be a full URL.
Examples
If you have created a 404.shtml and uploaded it to the root directory of your domain example.com, page your .htaccess file would have a line likethis:
ErrorDocument 404 http://www.example.com/404.shtml
If you wanted to use a 404.php script file you have written it would look like this:
ErrorDocument 404 http://www.example.com/404.php
If you would like people to be redirected to the homepage when they reach a non-existent page, you could use a line like this:
ErrorDocument 404 http://www.example.com/
A .htaccess file controls the directory in which it sits, and all subdirectories. However, by placing additional .htaccess files in the subdirectories, other .htaccess files can be overruled.
For more information you can refer to the following resources:
http://httpd.apache.org/docs/1.3/mod/core.html#errordocument
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
- 0 Users Found This Useful
Related Articles
Powered by WHMCompleteSolution