Redirecting Your Reader to a CGI script when an error occurs.
Redirecting your readers to a CGI script works exactly like
sending them to an HTML page from their perspective, but it
can be a timesaver for you as a webmaster.
By calling a script, you have the opportunity to both handle
the reader, and log the information. This can help you track
down problems a lot faster than searching through your logs
for errors.
To redirect a reader to a CGI script
when they encounter an error, you can either modify the
srm.conf file if you have
the ability to do so, or to modify your
.htaccess file.
In the srm.conf file you
will find a line that looks like this:
#ErrorDocument 404 /cgi-bin/missing_handler.pl
To specify a special script, remove the # mark and and
provide the name of your script.
ErrorDocument 404 /cgi-bin/missing.cgi
If you do not have access to the master system files, you can add
the line as shown above to your .htaccess
file. In order for this to work, the system administrator must make
certain that the AllowOveride option called FileInfo is set. You should
try to obtain AllowOveride All on your directories.
You can of course have a specific script for each error code:
ErrorDocument 400 /cgi-bin/badreq.cgi
ErrorDocument 401 /cgi-bin/noauth.cgi
ErrorDocument 403 /cgi-bin/forbid.cgi
ErrorDocument 404 /cgi-bin/missing.cgi
ErrorDocument 500 /cgi-bin/conferr.cgi
Personally, I feel it a better idea to just have one script and
pass the error code as the QUERY_STRING.
ErrorDocument 400 /cgi-bin/birdtrap.cgi?400
ErrorDocument 401 /cgi-bin/birdtrap.cgi?401
ErrorDocument 403 /cgi-bin/birdtrap.cgi?403
ErrorDocument 404 /cgi-bin/birdtrap.cgi?404
ErrorDocument 500 /cgi-bin/birdtrap.cgi?500
Want to know how to write such a script? We just happen to have
one for you, BIRDTRAP!
Of course its free!