Custom Error Pages

We all know what a 404 "Not Found" error page looks like. This tutorial will show you how to make those error pages anything you desire.

First you'll need to create your error pages. Just make some normal HTML pages, one for each error type. The error types and their definitions are:

  • 400: Bad Request. The server doesn't understand the request.
  • 401: Authentication Failed. The password was not accepted.
  • 403: Access Forbidden. Access to the area is forbidden.
  • 404: File Not Found. The requested file could not be found.
  • 500: Internal Server Error. Usually the result of a misconfigured script.

Once you've made your error pages, upload them to a directory called error or something of the sort.

Now the important part. Create a file called htaccess.txt in Notepad. Add these lines to the file:

ErrorDocument 400
ErrorDocument 401
ErrorDocument 403
ErrorDocument 404
ErrorDocument 500

Change to the location of your website. Save the file and upload it to your top-most web directory. Once it's there, rename it with your FTP program to .htaccess - complete with the dot starting it out, and with no .txt extension this time.

If the .htaccess file is in your top-most web directory, then all errors that occur in that directory and all its subdirectories will be referred to the appropriate error page.

That's it! Try it out by going to a page on your website that you know doesn't exist.