[an error occurred while processing this directive]

Site Menu

HTML
Learn all about HTML, how to format text, add images, create tables, meta taga, and more!
.
JavaScript
Get the low down on JavaScript. See how to create popular JavaScript applications like drop down menus, clocks, dynamic messages, popup boxes, and more.
.
CGI
Concise, easy to follow introdction to CGI and how to install CGI scripts.
.
Web Design
A miscellanous section that includes various web design tutorials

 

123 Web Design!

Creating a CGI redirect page

This tutorial written by Wsabstract.com

A redirect page is one that, well, redirects the user to another page upon entering, and is commonly used when a site or certain webpages have changed location. In the past, we looked at how to use either HTML and JavaScript to construct it; in this short tutorial, allow us to cap things off by illustrating a third technique- CGI.

A CGI based redirect page is required whenever the original page to be redirected from is a CGI document. No JavaScript or HTML code will do, since CGI documents are interpreted by the server, and requires actual CGI codes in them.

Without further adui, here's the CGI equivalent of a HTML/JavaScript redirect page:

#!/usr/bin/perl

print "Location:
http://newdomain.com/newfile.pl\n\n";

Simply copy the above two lines into your text editor, replace the part in red with the destination URL of your choice, and save it as the file name of the old CGI document (ie: "oldfile.pl"). Also, make sure the first line of the script, #!/usr/bin/perl, is the correct path to the Perl interpreter on your server. In some cases, it is #!/usr/local/bin/perl instead.

As an example of a CGI redirect page in action, go to http://wsabstract.com/cgi-bin/Utimate.cgi It automatically takes the visitor to our new forum location, http://freewarejava.com/cgi-bin/Ultimate.cgi, and uses exactly the code above to accomplish this.

Congratulations, you are now officially a page redirect Jedi!