How do I setup Custom Error Pages with a .htaccess file?

Often these pages have a link back to the referering page, and might show you the URL that you tried to access. That is easily accomplished with a little CGI, PHP, or even creative use of SSI's, but that's beyond the scope of this little resource page.

These pages are examples of Error Documents. The top table is the default, and the bottom table is an example of what you can replace it with. You can even have one for each directory if you want... (linking to /gadgets instead of / for example.)

Most types of errors that the web server can run into have error numbers. For example "Not Found" is error 404. ( List of Errors below.) The specification of an error document is easy. You add "ErrorDocument", the three digits of the error number and the either the error string or the page to go to. The following examples show the three forms:

ErrorDocument 401 You have to BUY a subscription!
ErrorDocument 403 /gadgets/htaccess/forbidden.html
ErrorDocument 404 /gadgets/htaccess/notfound.html
or (the less preferred form:)
ErrorDocument 404 http://baremetal.com/gadgets/htaccess/notfound.html

Error in Client
Number Description
400 Bad Syntax
401 Unauthorized
402 Not Used (Payment Granted)
403 Forbidden
404 Not Found
Error in Server
500 Internal Error
501 Not Implemented
502 Overloaded
503 Gateway Timeout



If you have any suggestions for or problems with this website, please e-mail
support@mercuryd.com