Home     SSI Lab     CSS Templates     CSS     Htaccess     Web Design     XHTML

Htaccess Tutorials

graphic-img   

SSI-D HOME

SSI LAB

CSS Templates

CSS

.Htaccess

Introduction

Experimental

Web Design

(X)HTML

HTML-Kit

Resources





Custom Error Documents

Bookmark with StumbleUpon
del.icio.us
Digg it
reddit
Furl
Spurl
ma.gnolia
Yahoo MyWeb
Windows Live
Sponsors

Introduction::

It can add a very professional touch to a site if you have customised error documents. With .htaccess you can very simply specify Error documents to use in place of the boring default documents.

You should be mildly familiar with Error codes to use this but I am sure you must know the common ones like Error 404: File not Found or Error 500: Internal Server Error? A simple Google search will provide much more details. There are quite a number of Error codes but I recommend you concentrate only on the ones I have listed below.



Error Documents

Place the following in your .htaccess file to specify the location of your custom error documents:

ErrorDocument 400 /error/400.htm
ErrorDocument 401 /error/401.htm
ErrorDocument 403 /error/403.htm
ErrorDocument 404 /error/404.htm
ErrorDocument 500 /error/500.htm

This breaks down as the word ErrorDocument, the error code then the path to your custom error document. This code must all be places on one line. And one line per ErrorDocument like in the example above.

You can actually add some HTML into the lines above but personally I think it would be wasting both your time and my time getting into that. If you are curious mail me.


The 5 Error Codes above are the ones that I recommend you customise. I would not bother with any other codes.



Error 400: Bad Request

Example: Our web server could not process the request submitted due to a bad command or syntax.

Erm...one of those errors you just get! No idea why!



Error 401: Authorization Required

Example: Our web server could not process the request submitted due to the fact that you are not authorized to enter this restricted area of our site.

Trying to access a password protected area, if you gave a wrong password etc etc.



Error 403: Forbidden

Example: Our web server could not process the request submitted due to the fact that you have attempted to enter a forbidden area of our site.

Not quite the same as a 403, more to do with accessing site files or directories which are protected by permissions. Trying to access a directory which has no default page such as an images directory, might return this error.



Error 404: File Not Found

Example: Our web server could not process the request submitted due to the fact that the file or script could not be found.

Bloody common error. Basically the file no longer exists that the use is requesting. You'll get this if a file has changed name or location and you are trying to access it via it's old URL. Avoid this on your site, very unprofessional.



Error 500: Internal Server Error

Example: Our web server has encountered an unexpected condition that currently prevents it from fulfilling the submitted request.the server encountered an internal error or misconfiguration and was unable to complete your request.

I get this all the time. Very common if you have wrong permissions set on CGI scripts etc.


As I said there are many Error Codes but I recommend that you cover these and not bother with any of the others. But investigate them none-the-less!