• 21 Dec 2008 /  Web Design

    You’re probably familiar with any major company having a nice, custom page when you land on a page that no longer exists. In this post, I will describe how you can add your own custom error pages with htaccess (assuming you are the webmaster).

    First off, here are some common error codes and what they mean:

    400: Bad Request
    401: Authorization required
    403: Forbidden
    404: Page not found
    500: Server error

    Now, those might not mean much to you, but the most common error page and one that you should set is 404. If you so much as rename a file, visitors may be coming from google and the file doesn’t exist. Instead of seeing a bland white page (or your host’s 404 page), you should change it.
    Here’s a sample .htaccess file

    ErrorDocument 404 /404.html
    ErrorDocument 500 /500.html
    ErrorDocument 400 /400.html
    ErrorDocument 401 /401.html
    ErrorDocument 403 /403.html

    You don’t have to name the file to match the error number, you can name the 404 error page “GoodbyeWorld.html” if you wanted.

    Now: Some tips for creating this file. On Windows, you cannot easily create this file. It doesn’t like having only extensions for filenames. To solve this problem, simply create your file and name it htaccess or htaccess.txt. Then, upload it to your web server and from there you can change its name (from ftp or a control panel).

    The most common problem people may face is due to their hosts: Many hosts, more specifically, many free hosts do not allow you to have a custom .htaccess file.

    Tags: ,