Blog Tools MISC

How to setup Custom Error Pages

- Tuesday, January 24, 2012

Custom Error Page allows you to have your own custom personal error pages instead of using the web hosting provider’s error pages or having no page. This makes a website look very much professional in the unlikely event of an error. Web master can also write scripts to notify him if there is an error.

Example: I use a PHP script on to automatically e-mail me when a page is not found. These are some of the most common errors:

The .htaccess file is what Apache web servers use to allow you to fine-tune your web server configurations at a directory level. Other types of web servers handle the customization of 4xx error pages differently.

How to Set Up A Custom Error Page

Step One

//Custom 400 errors
ErrorDocument 400 <local-path>/error-400.html

//Custom 401 errors
ErrorDocument 401 <local-path>/error-401.html

//Custom 403 errors
ErrorDocument 403 <local-path>/error-403.html

//Custom 404 errors
ErrorDocument 404 <local-path>/error-404.html

//Custom 410 errors
ErrorDocument 410 <local-path>/error-410.html

Step Two

Creating Your Error Document File: http://www.example.com/error-4xx.html
It is not good enough to simply let your visitors know that the file could not be found. In order not to lose them, you will need to provide them some way to locate the document they want, or they will leave.

Your page should have one or more of the following things:

Step Three

Testing the Error Document - When you're satisfied with your page, upload it together with your .htaccess file to your website. Then test it by typing a URL that you know does not exist. Your error page should load up. From this error page, test to see that the links here lead to the pages you intended it to lead.

Social Share

About the Author