Most servers default to the “standard” Apache error message pages for most common browser errors. If you want to develop your own error pages, you’ll need to define those pages in a file named .htaccess
, which you upload into your main www
directory. The custom error pages that you develop also need to be uploaded into your www
directory.
401 Authorization Required
This is the page that’s displayed when a user attempts to enter a password-protected directory with an incorrect login and password. To define your custom error page as authorization.html, add the following line to your .htaccess
file:
ErrorDocument 401 /authorization.html
403 Access Forbidden
This is the page that’s displayed when a user attempts to enter non-web-enabled directory (e.g., this page will be displayed when the user attempts to enter a directory that does not have an index
page defined. They’ll also get this page if your account is disabled.) To define your custom error page as access.html, add the following line to your .htaccess
file:
ErrorDocument 403 /access.html
500 Internal Server Error
This is the page your visitors see when there is an error processing a CGI script. To define your error page as ise.html, add this line to your .htaccess
file:
ErrorDocument 500 /error.html
Note: If the full URL of your site is http://www.yourdomain.com
, /error.html
means its location is http://www.yourdomain.com/error.html
.
Error Codes
There are a number of possible errors that a visitor might encounter. Each of these errors is associated with a numeric code (e.g., 401, 403, 500 as described above.) You can develop your own error document for any of these codes:
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 | |
500 | Internal Server Error | |
501 | Not Implemented | |
502 | Bad Gateway | |
503 | Service Unavailable | |
504 | Gateway Timeout | |
505 | HTTP Version Not Supported |
We also have a post about custom 404 pages.