[an error occurred while processing this directive]


Custom Error Messages

PLEASE NOTE: It's now possible to have different custom error pages for different directories. You can now also use any filename for your custom error pages that you want -- including filename.shtml which will allow you to use server side includes! Read on for more information.

Creating Custom "Not Found" and "Unauthorized" pages.

WebCom users have the ability to create custom error pages that are returned when a visitor tries to access a file that does not exist, or incorrectly enters password authorization information for a directory. This means that each domain name (that it is pointing to a different directory) can have error messages that conform to the overall style of the site, and information or instructions that are specific to that site. If your site is not accessed through your domain name, (such as http://webcom.com/~webcom/userid/), the WebCom error message will be displayed.

The .htaccess File

This is where everything starts. The .htaccess file is a file which tells our server where your "not found" and "unauthorized" error message pages are. Any directory in a website can have its own .htaccess file which determines the custom error pages for that particular directory. If a directory is lower in the directory structure (a subdirectory) and does not have it's own .htaccess file it will use the .htaccess file in the directory above it, if there is one. If there are no .htaccess files in a the directory or in any of the web directories above it, the default WebCom error messages will be shown instead.

The .htaccess is a very simple plain-text file that you can created with Notepad, Wordpad, Editpad, or similar text editors. It can contain two lines. One line tells our system which page to display for the "Not Found" error message. The other line tells our system which page to display for the "Unauthorized" message when someone fails an attempt to log into a password protected directory. You can use one or both or either of these directives in your .htaccess file. If you leave either of these directives out, the default WebCom pages will come up instead. When you created your .htaccess file, make sure that it is a text document, and make sure that the file name is exactly ".htaccess".

Here is a sample .htaccess file:

ErrorDocument 404 http://webcom.com/~webcom/help/ ErrorDocument 401 /help/acc_auth.shtml

In the sample above, 404 stands for "Not Found" and 401 stands for "Unauthorized". If someone followed an broken link or entered an invalid URL they would generate the 404 Not Found response which is to be directed (in this case) to the WebCom help page. If the directory was password protected, and the person failed to enter a correct userid and password, they would be directed to WebCom's Access Authorization help page. This is just an example. For your site you would probably want to create your own page that contains an error message and have the .htaccess file point there.

There are two interesting things to point out in the example above. The first thing is that the 404 URL can be fully-qualified. It can start with http://. This means that if you want to, you can point your to any valid URL, including ones on other websites. Meanwhile, for the 401 message you must list a local file path, or it won't work correctly. The second thing to point out is that you can point to any file type. In the example above I point to a .shtml (server side include) file, but you could also point to .htm, .html, or any other type of file. It even works with images and sounds!

Guidelines for Custom Error Pages

Because the custom error pages are simply HTML pages, there are no special guidelines that you need to adhere to. Normally the goal of a custom error page is to have a page that is consistant with the look and feel of the rest of your site, but your error messages can say whatever you want. We do recommend, however, for your page to provide an appropriate error message, and a link back to the home page.

Troubleshooting

You you're getting an error message instead of the file you're pointing to, try replaces the spaces in your .htaccess files with tabs.

We have found that browsers will sometimes cache a custom error page and continue to show it from memory even after the error-causing problem (such as a missing page) has been fixed. This problem is very rare and normally only happens when a missing page is uploaded to fix a problem, and a copy of the error message file is uploaded with it. This can happen when you use publishing tools which upload all of your files at once.

If your site encounters the problem of showing an error message even when there is no problem, your browser (or your visitors' browsers) may be caching your error page. You can compensate for this by including information in the headers of your error message page that tell browsers not to cache that page. Click here for a sample not found page which contains this header information. Also, because a small percentage of browsers do not support the tags that prevent caching, you might wish to include a note on the error page asking the visitor to reload the page and/or clear their browser cache, if they believe the error message to be old or incorrect.

[an error occurred while processing this directive]