Some people only know about .htaccess utility in apache rewrite, but it can do more than that. For example it can help you specify your own Error Documents. When ever a browser makes a request for a web document ( webpage, files, images, css files etc) the server returns a header that contains an error code that tells the browser details about the requests. I will list this codes below:
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
In order to In order to specify your own ErrorDocuments, you need to know these error codes, since you will need to specify for wich error code you want to assign a page.
But you wont need to specify an error page for all those codes, You only might want to do a custom error page for the most common of them like 404 and 500. Also most people do a custom Error Document for
401 – Authorization Required ( for sections of the site that are protected by a folder password and somebody tries to enter a protected area without corect login details ),
403 – Forbidden ( for example when someone is trying to access a folder withough an index option )
400 – Bad Request, which is one of those generic kind of errors that people get to by doing some weird stuff with your URL or scripts.
The advantage of having custom error documents is that you can display to the user a custom page with the site layout ( instead of the simple default one ) and you can even build a script to make custom logs of this errors.
You shouldn’t make custom pages for all error codes, for example an ErrorDocument for code 200 would cause an infinite loop, whenever a page was found…this would not be good.
To specify your custom error documents, you will add a special command for this in the htaccess file:
ErrorDocument [code] /directory/errorDocument.html
For example an error document for 404 would be:
ErrorDocument 404 /errors/404.html
Now you told the server that when it has an error code of 404 to return the page http://yoursite.com/errors/notfound.html. The same principle apply's to all the codes.
As a small advice i would recommend you make a special folder for your error documents and also name them something that will show theyr error code and purpose. I put 404.html but you can do notFound.html for example. Also the error documents do not need to be html they can also be php,asp or other types of files.
If you dont want to make a special file you can add the html directly in .htaccess file
ErrorDocument 401 "<body> You have to to be a member to view this page.
To do this you need to keep in mind :
the ErrorDocument starts with a " but does not end with one ... that was not a typo 
the command should be on one line, including the HTML