How to make a local Error Handler

Visitors may try to load files in your directory which don’t exist. This may be due to a bad link in your site, but more likely the error is located in a search engine or a link on an external site or elsewhere on MIA.

You need to capture that attempt and tell the visitor how to find the file they're looking for and give them the opportunity to tell you about it. This is done more effectively the closer to the destination of the non-existent file that you can capture the attempt.

An attempt to load a non-existent file will generate an error code 404 in the server. The server responds by searching up the directory tree until it finds a file called .htaccess (no extension). The .htaccess file is an ordinary text file which contains either of two types of redirection instruction.

Example 1:

ErrorDocument 404

Example 1 redirects a client which tried to load any non-existent file in the directory or subdirectories to the local error-handler 404.htm

The 404.htm is an ordinary html document. See as an example.

This should contain the message explaining that the file was not found, links to indexes which you believe will reliably lead the visitor to any information in the relevant directory, and an email-button to the director.

Example 2:

Redirect /archive/marx/works/1840/com-man

Example 2 redirects a client which tried to load works/1840/com-man (an old file which has been relocated) to the directory works/1848/communist-manifesto.

Example 3: The same effect can be achieved by placing a redirect file in place of the redundant file.

To do this, an additional line of code must be placed in the header of an html file (

<META http-equiv="Refresh” content="3;URL=../../1848/communist-manifesto/index.htm">

The “3” here tells the client to wait 3 seconds before moving to the URL.