NPH Error Script to handle redirections based on 404 errors

Source of the script is available from here. The manual page for the script is reproduced below. If you wish to receive a mail message when nph-redirect.pl is updated or have any comments about the script, send me an e-mail message.

The current version is 1.4, released on 27 Aug 1999. Here are some comments on the current version:

Please note: There are several CWRU-specific items in this program -- most notably all of the references to the APAS functions and the CWRUWWW.pm library. These relate to our internal account structure for maintainers of information on our web server, and will have to be changed to accomodate whatever structure you have set up. At a bare minimum, you must:

  1. Update the contact information in "$APAScontact" variable in the configuration section
  2. Comment out the chunk of code beginning with the comment "Before we go any farther..."
  3. Remove the "use CWRUWWW;" line
  4. Replace the "CWRUheader()" and "CWRUfooter()" routines with whatever you want consistently at the top and bottom of all of your pages.
This will set all of your pages to return with the contact information of whatever you set up in the "$APAScontact" configuration line. Most of the routines you are removing is what we use to make it appear that the error message came from the maintainer of the web area where the problem is located. This greatly reduces the e-mail coming to our webmaster account which we cannot do anything about.


SYNOPSIS

nph-redirect.pl


DESCRIPTION

This script will run as a CGI to the Netscape Commerce server to intercept 404-document-not-found errors and redirect them to other locations if we can tell the user where to go; otherwise, return a standard error message with the added benefit of using the APAS maintainer's e-mail address rather than the main Aurora e-mail address.


SETUP

First, you need to configure this script's variables.

$SYS_RED_LIST
Full pathname of the file that declares server-wide redirections

$USR_RED_LIST
Name of file, which would appear in web document directories that contains redirections for files/directories in that directory (can be written by the user, not necessarily by the web administrator).

$RED_LOG
Full pathname of the redirection logfile

$errorMessageFile
Location of the portion of the normal 404 error message that will be sent to the user if the the redirection fails

$faviconFile
Location of the MSIE 5-specific favorites icon for the server

$SECONDS
Number of seconds in the META REFRESH delay for ``delay''-type redirections (see below for what a ``delay''-type redirection is).

$APAScontact
Default APAS contact, with the format <TAB>E-mail<TAB><TAB>Title text<TAB>

Also note, if you are not at CWRU, there are many customizations that you.will have to deal with. These include ``use CWRUWWW'' (our PERL library), CWRUheader()/CWRUfooter() (generating our standard headers and footers), and all APAS references (our database of information providers).


CONFIGURATION FILE FORMAT

The configuration file contains redirection specifications with the keyword/value format

keyword: value

One redirection tuple is made up of three to five parts:.

  1. An 'oldtarget'...the old path of the file in the web server. Note: directories must *NOT* end in a slash.

  2. A 'newtarget'...the full or partial URL of the new location. Note: directories *MUST* end in a slash.

  3. A 'type'...which can be one of four types:

    gone
    The target is gone and we don't wish to offer suggestions on where to go.

    force
    Force the user to click on the URL anchor to take them to the new location.

    delay
    Provide the opportunity for the user to click on the URL anchor to go to the new location, but also use a <META> REFRESH tag to take the user to the new location after a system-defined delay.

    quiet
    Quietly send the user to the new location using the ``Location:'' HTTP header. Also provide an HTML file with the URL anchor on the off chance that the ``Location:'' header didn't work or isn't supported.

  4. A 'message', which is used as an alternative to the predefined redirection message. This is a complete file name in the UNIX file space where the message is. The message is inserted between the standard header and footer.
  5. A 'position'...which specifies whether the 'message' is before or after the bit of generated text that tells the user where the guessed new location is (only applies to ``force'' types).
For example:. oldtarget: /lit/homes/sully newtarget: /dms/homes/sully/ type: force oldtarget: /dms/homes/sully/resume.html newtarget: http://www.cwru.edu:80/dms/homes/sully/resume.html type: force

The file can contain comments by beginning the comment with a ``#'' character, lasting until the end of the line. Lines can be continued to the next line but using the "\" character at the end of the line.


COPYRIGHT

Copyright 1997 by Case Western Reserve University.


AUTHOR

This program is based on RedMan Version 2.10 (7Nov95) The main RedMan WebPage is http://sw.cse.bris.ac.uk/WebTools/redman.html. Major revisions by jrp 5/96--cleaned up html for error message, made files/subdirectories under redirects work with ncsa 1.5.1

 Peter Murray
 Library Systems Manager
 Digital Media Services
 Case Western Reserve University
 pem@po.cwru.edu
 http://www.cwru.edu/home/pem.html

Updates available from http://www.cwru.edu/dms/homes/pem/projects/nph-redirect.html