Htaccess - Error Documents
Author: XEN
Filed Under Web Development |
I never regarded the ErrorDocument “feature” of htaccess as being useful, only because I hate confusion… and seeing different error pages for each website is very confusing, it gives you a headache.
However ErrorDocuments can be used wise in a busy article website, a good example would be redirecting users on a 404 page to pages related to the url. Or redirecting a wrong article request to the article’s directory. The only problem in this would be that the search engines will get 404, but the user would get a different page.
This is a list of status codes:
Successful Client Requests
200 - OK
201 - Accepted
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
Not all error codes should have error pages, some are more necessary than others. You should not create an error document for the 200 Status Code because this is the “OK” code, it tells the browser that the page is ok, creating a document for this status code would cause an infinite loop. Because the same status code is returned for the error document.
You can use html as the Error document, the html code needs to be all on one line (no word wraping) and the quotes only need to be placed on in front of the html, here’s an example:
ErrorDocument 404 "<b> Specified page was not found</b>. <u>Please check the url and try again</u>
Apache, Coding, Errors, Htaccess, HTML, Web Server
Comments
Leave a Reply
You must be logged in to post a comment.

