#!/usr/local/bin/perl
# *********************************************************************** #
# * * #
# * Copyright (c) 1996-1999 Scott Crevier * #
# * All Rights Reserved Worldwide * #
# * * #
# * This program product material is the property of Scott Crevier. * #
# * This program may be used and modified by anyone free of charge, * #
# * as long as this copyright notice remains in tact. By using this * #
# * code, you agree to indemnify Scott Crevier from any liability * #
# * that might arise from its use. * #
# * * #
# * scott@crevier.org - Scott M. Crevier - www.crevier.org * #
# *********************************************************************** #
# * smcHttpError v2.0 21-Dec-1998 * #
# * * #
# * This script is used to capture web server error codes and give * #
# * the user a kinder gentler error message. You can customize it so * #
# * it uses your logo. I have coded this script to handle three * #
# * different kinds of errors; but if you look at it, you should be * #
# * able to add more if needed. * #
# * * #
# * I invoke this script by putting the following lines in my * #
# * .htaccess file. Both the .htaccess file and this script reside * #
# * in my public_html directory. * #
# * * #
# * ErrorDocument 401 /http_error.pl * #
# * ErrorDocument 403 /http_error.pl * #
# * ErrorDocument 404 /http_error.pl * #
# * * #
# * Additional information regarding error-handling scripts can be * #
# * found at: * #
# * * #
# * http://hoohoo.ncsa.uiuc.edu/docs/setup/srm/ErrorDocument.html * #
# * http://hoohoo.ncsa.uiuc.edu/cgi/ErrorCGI.html * #
# * http://www.apache.org/docs/custom-error.html * #
# * * #
# *********************************************************************** #
# *********************************************************************** #
# * Some variables. You should not need to change these. * #
# *********************************************************************** #
$errno = ($ENV{'REDIRECT_STATUS'} eq '') ? "404" : $ENV{'REDIRECT_STATUS'};
$url = $ENV{'REDIRECT_URL'};
$domain = $ENV{'HTTP_HOST'};
# *********************************************************************** #
# * Set these variables to match your setup/needs. Most of the error * #
# * messages are pretty standard, but of course you can set the exact * #
# * text to be whatever you want. * #
# *********************************************************************** #
$ERRMESG{'401'} = "Unauthorized";
$ERRDESC{'401'} = "User authentication failed.";
$ERRMESG{'403'} = "Forbidden";
$ERRDESC{'403'} = "Sorry pal, you are not permitted to perform this request.";
$ERRMESG{'404'} = "File Not Found";
$ERRDESC{'404'} = "The requested URL http://${domain}${url} was not found on this server.";
# *********************************************************************** #
# * Print the web page. * #
# * You can customize this web page to your liking. Maybe add your * #
# * company logo and/or your e-mail address or whatever. * #
# *********************************************************************** #
print "Content-type: text/html\n\n";
print <
$errno $ERRMESG{$errno}
$errno $ERRMESG{$errno}
$ERRDESC{$errno}