|
Perl Case Study - Redirect CGI This case is pretty simple; there is only one essential line that will make this script redirect to another URL (or page). The following basic script will do just that:
#!/usr/local/bin/perl $url = "http://3dinfinity.com/aiw/"; # destination of the redirection print "Location: $url\n\n";
See this script in action: redirect.cgi What did that do? It just sent you to a predefined URL. The important line was printing "Location: URL\n\n" which is the whole mechanism that redirected you to the URL. I set it as a variable so that you can use other routines to predetermine the redirection destination. For example, you can have the script take in an environment variable, like $ENV{'QUERY_STRING'} (redirect.cgi?TheQueryString), and based on that information, select a link from a list or hash you define in a script or in a file. You can even open a file and get the necessary information before computing and deciding what the URL destination should be.
|
||||||||||
©1999 Team 26297 "Ad Infinitum Web." All rights reserved. Any reproduction of this document for commercial or redistribution purposes without the permission of the author is forbidden.