Error Page Codes

What are Error Codes?

These numbered error codes are how the Web server tells the user about a status or error encountered. There are many different error codes that a server can deliver, but these are a few of the more common codes.

401 : Unauthorized
Access to the URL resource requires user authentication which either has not yet been provided or which has been provided but failed authorization tests. This is commonly known as "HTTP Basic Authentication". Unless you have a good reason to do so, it is not recommended to redirect a 401 error.

403 : Forbidden
The request was a legal request, but the server is refusing to respond to it. Unlike a 401 Unauthorized response, authenticating will make no difference. This is usually due to a scripting or permission(s) issue.

404 : Not Found
This response code indicates that the client was able to communicate with the server but either the server could not find what was requested, or it was configured not to fulfill the request and not to reveal the reason. Error 404 should not be confused with "server not found" or similar errors, in which a connection to the destination server cannot be made at all.

500 : Internal Server Error
Your Web server encountered an unexpected condition that prevented it from fulfilling the request by the client (e.g. your Web browser) for access to the requested URL. This is a 'catch-all' error generated by your Web server. Basically, something has gone wrong, but the server can not be more specific about the error condition in its response to the client.

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 is located in the /public_html/ directory in your account. Add-on domains have their very own .htaccess file, it is located in /public_html/{add-on domain}/. A .htaccess file may already be present. If that is the case, then you can just add these lines to it. Otherwise, you can just create a new, empty .htaccess file to add these lines to it.

The correct format for an error document statement in a .htaccess file is as 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 add-on 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, your .htaccess file must contain the following line before the new error document would successfully be used:

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 sub directories under it. However, by placing additional .htaccess files in the sub directories, 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
Was this answer helpful?

Related Articles

 Cpanel user manual

cPanel 11 Documentation Introduction The purpose of this documentation is to provide as much...

 Mysql database and user naming syntax

Since we run a shared hosting environment, we have to uniquely identify your usernames to your...

 How do I password protect a folder?

Within your Overline India control panel, you have the ability to password protect a folder...

 How do I backup my site in cPanel?

It is important to have your own backup procedure in place to protect yourself from losing all...

 Can I add an auto responder to my emails?

An auto responder can be setup in cPanel to respond to any incoming emails with a message...