info.html 000644 002126 000144 00000016023 06204675775 013472 0 ustar 00igraham staff 000000 000000
[Software (UP)] [Ian Home] [Webinfo ] | Software Resources |
Page Last Updated: 21 July 1996 |
Latest Software: Version 1.0 |
On this Page: General Info | SSI Document | Gateway Prog. | Download You can print this page as a reference/tutorial |
Redirector is a simple CGI+Server-Side Include package for displaying redirection information for moved files. The purpose of the package is threefold:
The package consists of two components. The first part is an HTML document template that contains the outline of an HTML document, and that uses SSI (Server-Side Includes) to inlcude the output of the forwarding program. The second part is the forwarding gateway program, forward.pl, which provides the content for the returned HTML document (via the SSI mechanism) and which returns the correct URL for the moved document. This is a Perl, Version 4 script, but it is simple enough that it should work properly under Perl, verison 5.
- To notify the user of the changed URL, and to provide the new value;
- If referred to this location from another document, to inform the user of this fact, and to suggest that he/she request that the page be corrected.
- Optionally, to record a list of refer URLs. This can be used by a batch program to examine refer URLs and send letters to the page managers, asking that the URL referencing this document be corrected.
Each document is replaced by a server-side include document of the form:<HTML> <HEAD> <TITLE> This Document has Moved !!</TITLE> <META HTTP-EQUIV="Expires" CONTENT="Mon, 01 Apr 1996 09:00:00 GMT"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> </HEAD> <BODY> <!--#exec cgi="/cgi-bin/forward.pl" --> </BODY> </HTML>where forward.pl is the gateway program that does all the work. This document must be parsed by the server as a server-side indlude document. With NCSA, Apache or Netscape servers, this means that the document must have the execute bit set. An example procedure for doing this is shown below.Note that the path to forward.pl must be correct: if you have this CGI program in another CGI program directory, or if you change the name of the program, you must modify the referring HTML documents.
2.1 If Moving a Single Document
Suppose the document that is moved is named duckling.html, and that the forwarding document is named forward.html. What we need to do is (i) move the duckling out of the way; (2) copy forward.html in place of duckling.html, and (3) mark the file as executable. The UNIX commands for doing these three things are:mv duckling.html duckling.html.orig #move duckling.html out of way cp forward.html duckling.html #copy forward.html into place chmod +x duckling.html #mark duckling.html executable2.2 If Moving a Group of Document
This is similar to moving a bunch of single document, except that you do not need to make multiple copies of the forwarding document -- you can just make links from a generic forwarding document to a single copy. We will assume that the single file is forward.html The general format is (herefile
refers to all the files you want to redirect):chmod +x forward.html #mark forward.html executable mv file.html file.html.orig #move files out of way ln forward.html file.html #link all files to forward.html
The gateway program is very simple, and requires that you specify two things: the base URL for the new location of the documents,
$new_base_url
, and the base URL of the old location of the documents,$orig_base_url
. Consequently, with the current version of the program, you need a different program for each moved directory hierarchy.The program gets the URL of the document being accessed from the environment variable DOCUMENT_URI -- this will simply be the path to the document, as seen by the server. The original URL of the document is then the combination of this variable and the original base URL (
$orig_base_url+DOCUMENT_URI
), and the new URL can be similarly constructed.3.1 Referer Information
Some browsers send referer information, to indicate the document from which the current link was accessed. This is passed to the gateway program through the environment variable HTTP_REFERER. If this variable is present, the program also prints this information out, and includes text that asks the user to fix this referring page, or to send mail to the manager of the page so it can be fixed.3.2 Database Version forward-dbm.pl
For some pages, you may wish to maintain a database of all the referring pages: that way, you can yourself access these pages, check for feedback mail addresses, and send them mail asking that they fix the links. The second program forward-dbm.pl is identical to forward.pl, except that it uses DBM to create and update this database.
You can access the files by themselves, or as a UNIX tar archive. Here are the links:
- redirect.tar (tar archive)
- forward.pl (Main perl program)
- forward-dbm.pl (Main perl program -- with DBM support)
- utils.pl (functions required by both forward.pl and forward-dbm.pl)
- countries.pl (function required by forward-dbm.pl only) DBM)
- redirect.html (Example HTML source listing)
[Software (UP) ] [Ian Home] [Webinfo ] | Software Resources |
[Software (UP) ] [Ian Home] [Webinfo ] | Software Resources |