htaccessWeb Developer

Make Custom Error Pages for Your Website (using htaccess)

Written by:

Add some extra bit of flare to your website with custom error pages. 404 errors or 501 errors, customize them all. Maybe even give your users a useful link or just some clever word play. Creating these sweet display pages for your users is quick and easy with your htaccess file. Best part? One line of code per error page. It is so simple!

Different Types of Error Pages

  • 404 error: Page not found – perhaps the most common error page, the 404 error is given when the web page or file you are trying to access does not exist. Like if you fat-fingered the folder name or if the file was deleted off the server.
  • 403 error: Forbidden – error given when the access to the specific file or folder is unauthorized. Commonly used for when an administrators wants to restrict access to an entire folder.
  • 401 error: Unauthorized – this error is given when the user is trying to access a page or folder that is restricted and they do not have permission for. This can also be given after multiple failed login attempts.
  • 500 error: Internal server error – this is a generic error message that a web server will give for any of the internal errors that it may receive, (e.g. server being overloaded or a coding error in some files).

How to get custom error pages

To get your own error pages for your site, just open up your .htaccess file for editing. Once it is open, you just need to add one line of code per error page.

Check this out:  Change user password for phpMyAdmin and Update MySQL account password

Create your custom error pages and save it as a separate html file (e.g. 404.html). I usually like to save all of my custom error pages into a folder for just the error pages (e.g. “errors”). It just makes my life more organized, you know?

Open your .htaccess file and add the following line of code to it:

ErrorDocument 404 /errors/404.html

You can easily add additionally custom error pages by listing the error code number and the relative location of the html file for that error. Like this:

ErrorDocument 500 /errors/500.html

Free Error Page Templates? Yes please!

Sometimes I don’t feel like creating my own error page. The long time it takes to get the design and style just right can take forever. How about using some free templates?

If you are not looking to create your own custom error pages, then you can find some free to use ones at the links below. There are some really clever and unique pages on there:

Leave a Reply

%d bloggers like this: