Login Form



Latest Comments

Home : Htaccess Tips : Creating Error Documents For Server Errors

Creating Error Documents For Server Errors

E-mail
Saturday, 23 June 2007 16:49

Web Site Error Documents


Many times and SEO expert must know how to tweak .htaccess file. I must say it is essential to know how to do different redirects, tweaks, setting the error documents etc.

The error documents can be set in the .htaccess file that we talked earlier about. First let’s take a look of the list of the server returned error codes after that we will tweak our .htaccess file.

Successful Client Requests

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

Client Request Redirected

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

Client Request Errors

400 Bad Request
401 Authorization Required
402 Payment Required (not used yet)
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable (encoding)
407 Proxy Authentication Required
408 Request Timed Out
409 Conflicting Request
410 Gone
411 Content Length Required
412 Precondition Failed
413 Request Entity Too Long
414 Request URI Too Long
415 Unsupported Media Type

Server Errors

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


We must not specify an error page for each of these errors.

For example an Error Document for the error code 200 would cause our site to loop endlessly whenever a page was found – well we do not want that.

We would probably only need to create documents for the server error code 404 and 500, 400 means that the page can’t be found and we need to create a document for that error where we can point the users to the homepage for example.

500 error document would help when our site gets internal server errors in any scripts that are running on our site.

Also we can setup the error page for the 401 - Authorization Required (when a visitor tries to enter the protected area without the proper password etc), 403 - Forbidden (where the file with permissions is not allowed to be accessed by the user) and error 400 - Bad Request, that is displayed when the users tries to do some strange things with our site URL or the scripts we are having on the site.

To setup these error documents you simply need to add the following lines in your .htaccess file:

ErrorDocument code /directory/filename.ext

or

ErrorDocument 401 /errors/notfound.html


In case a user gets an 401 error he is automatically forwarded to the page yourdomain.com/errors/401notfound.html

Another example:
ErrorDocument 500 /errors/500internalerror.html
You can simply select the name of your error pages and upload them to the correct directory or to the root of your server.
Usually the webmaster keep the error documents in the root of your server. But you can move them to the directory. In that case you have to specify the correct path for each error document in the .htaccess file. In this exmple the error documents are in the folder errors.
For example the .htaccess could look like this
ErrorDocument 400 /errors/badrequest400.html

ErrorDocument 401 /errors/authreqd401.html

ErrorDocument 403 /errors/forbid403.html

ErrorDocument 404 /errors/notfound404.html

ErrorDocument 500 /errors/server500.html



Comments
Add New Search
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."