URL Redirection

Michael Goshorn
October 23, 1996


  1. Problem

    A page previously stored on FortNet moved to another server and requested that a specific html file forward the viewer to the new URL.
    1. Issues:

      • Forwarding should work for all browsers
      • The old URL in question involved a specific html file rather than a directory specification with a default index.html file.
      • The existing directory did not contain an index.html file or symlink as required by the current html qa standards.

    2. Data:
      • OLD URL: http://www.fortnet.org/FortNet/business/cbba/cbba.html
      • NEW URL: http://www.pageplus.com/~cka/

  2. Solutions:
    1. cbba.html
      • Client Pull added to <HEAD> element of the file

        <META HTTP-EQUIV="REFRESH" CONTENT="2; URL=http://www.pageplus.com/~cka/">
        The 2 above specifies the number of seconds to wait before forwarding the viewer to the new url.

        This statement is recognized by Netscape and Internet Explorer. It is not recognized by lynx.

      • Some descriptive text and a link to the new page were added to enable lynx viewers to navigate to the new location.

    2. /FortNet/business/cbba/ directory
      • Perl cgi script was added as file index.cgi to forward references to the directory to the new URL.
        This script works for lynx and browsers tested.

        #!/usr/local/bin/perl5
        # Michael Goshorn October 20, 1996
        use CGI;
        my($q) = new CGI;
        print $q->redirect('http://www.pageplus.com/~cka/');
        print $q->end_html;

      • An alternate solution from Charles Clarke is /www/cgi-bin/redirect.cgi
        
        #!/usr/local/bin/perl5 -wT
        # Created by Charles Clarke
        # use with http://www.fortnet.org/cgi-bin/redirect.cgi/http://machine/path
        #
        my($path) = $ENV{'PATH_INFO'};
        $path =~ s|/http|http|;
        $path =~ s|^//|/|g;
        if ($ENV{'REQUEST_METHOD'} ne 'POST')
        	{
            print "Status: 301 Moved Permanently\n",
        	"Location: $path\n\n";
        } else
        	{
        	print "Status: 301 Moved Permanently\n",
        	"Context-Type: text/html\n\n";
        	print "<HTML><HEAD><TITLE>Page redirected</TITLE></HEAD>\n",
        	          "<BODY>This page has been moved to ",
        	         "<A HREF=\"$path\">$path</A>",
        	         "</BODY></HTML>\n";
        }
        	

  3. Comments:
  4. This is a good example of why URL's should specify a directory rather than a specific html file. In this case, the index.cgi script would have solved the problem in one step rather than three.


References:

  1. How can I redirect the browser to a different page? http://www.boutell.com/faq/redir.htm
  2. AN EXPLORATION OF DYNAMIC DOCUMENTS http://wp.netscape.com/assist/net_sites/pushpull.html


Home | Search | Help | Feedback

Copyright © 1998-2001 FortNet Inc.