jump to navigation


Posted by Tournas Dimitrios in Uncategorized.

Whenever a browser request data from a web server, the server must respond with a number.  The number indicates the status of the request (whether it has failed or successful, etc).  The number is taken from a set of codes called the HTTP protocol status codes.  HTTP itself stands for Hypertext Transfer Protocol. User don’t usually see the status code code because the browser parses the code internally; unless there’s a problem, that is.  For example, this kind of message should be familiar to you:This message means that the server has sent code 404 (which means that the server cannot find the data requested by the client).W

Ho Defines The Protocol Codes? The World Wide Web Consortium

Aliases : Also known as: HTTP status codes, or HTTP error codes, HTTP header status code .

In what format is the code being sent to the browser? In text format, with the following syntax:

Status: Code Info

For example:

Status: 200 OK
Status: 400 Bad Request

As said earlier, the server sent one of these message every time at the beginning of a data stream.  User don’t see these unless there’s an error.

List of the common codes :This list is not exhaustive, I’m just listing the common ones, and some explanation of what they mean.  If you’d like to view all the codes, go to: www.w3.org.

200: OK (Success)
This means that everything is ok.  User never sees this.

401: Unauthorized

The web server fails to authenticate the user.  This happens when a user failed to enter a password protected directory (such as below).  Common causes: the password entered by user is incorrect; the user is not an authorized user; the user pressed the CANCEL button.

403: Forbidden

This code indicates that the file is not for public view.  The user does not have the permission to read the file.  I.e.: the browser is trying to read a file that it isn’t supposed to read.  Usually happens if the file is not set to be publicly accessible.

404: Not Found

The most common error code of all.  It indicates that the browser is trying to access a file that is not available.  Possible causes:

  • attempting to enter a broken link
  • because the file has been deleted or moved from the server
  • the user has typed a wrong, invalid, or misspelled URL

500: Internal Server Error

Codes that starts with the digit 5 indicates that there’s a problem with the server. Code 500 indicates that the server does not understand the data.  (That basically means that the server got confused, or stuck.)   This often happens when executing a bad CGI scripts.  The browser might have received data without a content-type, thus not knowing what to do with it or how to display the data.  (I often got this error whenever I upload a CGI script in binary instead of ASCII mode.)

Customizing the Error Pages :On Apache servers, this can be done by editing a file called “.htaccess” on the www root directory.  Add the following line.

ErrorDocument protocolCode fileHandler


  • protocolCode is one of the protocol error codes
  • fileHandler is the file that you want to display whenever that error occurs

For this to work, the web server must have been configured to allow ErrorDocument override.  Contact the ISP if you’re not sure.

For example:

ErrorDocument 401 /badreq.html

will cause the browser to display the file badreq.html when a document is not found

ErrorDocument 403 /errDoc/forbidden.html

will cause the browser to display the file forbidden.html if an user tries to access a forbidden document.  Notice that the fileHandler can be located anywhere, but it must be referenced with absolute path (relative to the root directory of the www).

ErrorDocument 404 /cgi-bin/nf.cgi

will cause the browser to execute the script nf.cgi if an user failed to enter a password protected directory.

As can be seen above, you can change almost all of the error codes handler.  If you do not specify a handler, then the default will be used.  (The default might have been set by your server administrator; if not, then you will get the standard ugly message such as shown on the screenshots above.)

Reference: The World Wide Web Consortium


No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s