Most of the users that come to your site, will not know what a “Internal Server Error” or “404” error is. They will not bother to check out the Apache manual either.
Custom error messages are not something to (just) show off with. In terms of (web-)usability, you are able to display a more friendlier or meaningful message to your users, and everyone will live happier ever after.
A lot of people still ask me how to add custom error pages to their website. Since some ISPs charge an arm and a leg to add them, here is how it is done – for free!
You log onto your shell and create a file called .htaccess in your document root. This can be achieved if you type “pico .htaccess”, “ee .htaccess” or “joe .htaccess” on the shell prompt. Let’s assume that you want to display a custom error page for “File not found”-errors (code: 404).
Put the following code inside the .htaccess:
ErrorDocument 404 /path/to/error/document.html |
Save it. Viola! It’s all done.
You may also refer to a remote document:
ErrorDocument 404 http://errors.domain.com/404.php |
The syntax is as follows:
ErrorDocument <3-digit-code> action |
Can’t get enough of them?
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 |
Have fun!
Post Your Comment