Web Server Error Codes / Messages

Avitar.Net - Plan, Protect, Grow
Plan, Protect, Grow


Log In or Register
Search Site

Navigation

Keep The Project Going!
Donate to Project JAK



Avitar.Net / Web Server Error Codes / Messages

Abstract

Explains web server error codes and status messages that are sent to the browser targeted toward web server administrators.

Web Server Error Codes / Messages

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, i.e.:

 
ErrorDocument 404 errors/404.html
ErrorDocument 404 errors/404.shtml
ErrorDocument 404 cgi-bin/errors.cgi?err=404
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 www.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 www.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 Codes 1xx

Code Description
100 Continue
101 Switching Protocols

Successful Codes 2xx

Code Description
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content

Redirection Codes 3xx

Code Description
300 Multiple Choices
301 Moved Permanently
302 Moved Temporarily
303 See Other
304 Not Modified
305 Use Proxy

Client Error Codes 4xx

Code Description
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 Codes 5xx

Code Description
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:

Related