Home > Tutorials > HTACCESS Tutorials > Creating Custom Error Pages

Creating Custom Error Pages

One of the most common uses for a .htaccess file is to create custom error pages. The Apache server comes pre-installed with several different error pages, the problem with them is that they are quite frankly…. ugly. In order to use custom error pages we just need to add the following line(s) to our .htaccess file (for instructions on how to create a .htaccess file please refer to this post):

ErrorDocument errornumber /errorfile.extension

W e replace errornumber with the number corresponding with the Apache Error:

  • 400 -- Bad Request
    

  • 401 -- Authorization Required
    

  • 403 -- Forbidden
    

  • 404 -- Page Not Found
    

  • 500 -- Internal Server Error
    

errorfile.extension gets replaced with the name of the file you wish to use as your custom error page. You can place this file anywhere on your server, as long as you specify the directory it is in if it isn’t in the root directory.

Here are a few examples:

ErrorDocument 404 /404.php
ErrorDocument 401 /errorpages/401.shtml
ErrorDocument 500 /errorpages/500/500.html

About Michael Boguslavskiy

Michael Boguslavskiy is a full-stack developer & online presence consultant based out of New York City. He's been offering freelance marketing & development services for over a decade. He currently manages Rapid Purple - and online webmaster resources center; and Media Explode - a full service marketing agency.

Check Also

How To Populate A DIV via an HTML SelectBox, PDO, and jQuery

Imagine you have a database full of information, and you want to let users browse ...

Like every other website, this site uses cookies to analyze our traffic. Cookies may also be utilized by our advertisers and partners. By using this website you agree to the use of said cookies. More Information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings, continuing to navigate past this message, or you click "Accept" below then you are consenting to the use of cookies on the Rapid Purple website.

Close