Custom Error redirects with .htaccess

Cold hard website errors are horrible and unnecessary. All you need is a few nice looking .html files in your directory somewhere, then use .htaccess to reditrect to these when there is an error. Obviously, no errors at all would be better…. 🙂

The format for the .htaccess is :

ErrorDocument errornumber /file.html

For example, if the file notfound.html was in the root directory of my site and I wanted to use it for a 404 error I would use:

ErrorDocument 404 /notfound.html

If the file is not in the root directory of your site, you just need to put the path to it:

ErrorDocument 500 /errorpages/500.html

These are some of the most common errors:

401 - Authorization Required
400 - Bad request
403 - Forbidden
500 - Internal Server Error
404 - Wrong page

and they can all be redirected to the same page, different pages, or even a dynamic page….