Web Developer, Web Development, Software Development, System Administration Tools Resouce, Articles Resouce, Content Resouce, Information Resouce
Articles and Tools for Web Developers, Web Development, Software Development, System Administration
Common Error Codes When Surfing the Web

So your surfing the web and you end up seeing something like 404 Page not found. The average user is likely to say, "wtf teh suxorz 111". This means as a web developer you should know what the error codes are so you can fix them, and explain to your users what they mean in simple terms. Scary enough most error codes should be hidden from users and instead replaced with busy messages. This tactic is used by professionals to save face while buying some time to fix the problem from the user.

One easy way to handel errors is to use .htaccess files under apache, or a script to email the webmaster incase there is a broken link. Acctually logging is better though since email messages will clog your webmasters inbox quickly if you have a respectable number of users on your site.

The easiest and most common use of error handeling is .htaccess 404 for redirection to either a static or dynamic page.
ErrorDocument 404 errors/404.html
Or:
ErrorDocument 404 errors/404.shtml
Or:
ErrorDocument 404 cgi-bin/errors.cgi?err=404
Or:
ErrorDocument 404 error404.php

Another way of redirection under apache is via http rewrite rules? This is also easy. The following line can be used to redirect every not found URL to a different server/domain:
RewriteEngine on RewriteCond \%{REQUEST_FILENAME} !-f RewriteRule (.+) http://404.click11.com/$1

Yet another way of redirection under apache is via a per domain configuration using one of the above methods. Simply put, open your virtual host file for a given domain and use one of the above solutions to use an improved way of error trapping.

What about server side programs? Most server side programs should have built in error handeling. They can use the following line at near the top of their code for perl based programs to display what is wrong with the code.

Help Im using IIS and not Apache, is there a .htaccess equivelent in IIS? Yes there is a .htaccess equivelent in IIS!
  • Open Internet Services Manager and create a web site for domain.com.
  • Make the content directory for the site be the same directory, c:inetpubwww-domain-com, as www.domain.com.
  • Test getting content from http://domain.com.
  • Select the domain.com web site in Internet Services manager and enter the properties.
  • In the Home Directory tab, change the option button "When connecting to this resource the content should come from" to "A redirection to a URL".
  • Specify the URL as http://domain.com.
  • Check the checkbox that says "A permanent redirection for this resource."

Now test the pages by purposly making errors.

The Error Codes:

This is a list of error codes so you can make pages that express in a meaningfull way to the user what happened.
Informational 1xx
  • 100 Continue
  • 101 Switching Protocols

Successful 2xx
  • 200 OK
  • 201 Created
  • 202 Accepted
  • 203 Non-Authoritative Information
  • 204 No Content
  • 205 Reset Content
  • 206 Partial Content

Redirection 3xx
  • 300 Multiple Choices
  • 301 Moved Permanently
  • 302 Moved Temporarily
  • 303 See Other
  • 304 Not Modified
  • 305 Use Proxy

Client Error 4xx
  • 400 Bad Request
  • 401 Unauthorized
  • 402 Payment Required
  • 403 Forbidden
  • 404 Not Found
  • 405 Method Not Allowed
  • 406 Not Acceptable
  • 407 Proxy Authentication Required
  • 408 Request Timeout
  • 409 Conflict
  • 410 Gone
  • 411 Length Required
  • 412 Precondition Failed
  • 413 Request Entity Too Large
  • 414 Request-URI Too Long
  • 415 Unsupported Media Type

Server Error 5xx
  • 500 Internal Server Error
  • 501 Not Implemented
  • 502 Bad Gateway
  • 503 Service Unavailable
  • 504 Gateway Timeout
  • 505 HTTP Version Not Supported


Do you get problems viewing your pretty error pages now? Well this is actually probably a result of Microsoft trying to steal traffic from websites using their own "freindly" error handeling instead of yours.

To turn off this feature go to the following in Internet Explorer:
Open IE --> (menu) Tools --> Internet options --> Advanced --> (uncheck) show friendly HTTP error messages References:
Computer Consulting, System Administration, Methodology, Resume, Project, Management, Software, Development, Documentation, Articles Copyright 2003-2005 Avitar.net. Avitar.Net TM. All Rights Reserved. web development Consulting for System Administration Methodology Resume Project Management Software Development Documentation Web Developer