ITS LOGO August 2007

How do I ... logo Redirect a Web Page using a CGI-Script


Contents

Introduction

nph-redir is a cgi-script that allows you to redirect your web browser to a site you choose from a pull-down list, just by clicking a button. Because you can put many sites in the pull-down list, while the list only takes up a few lines on the screen, this can save you a significant amount of screen-space.

How to Use nph-redir

To use nph-redir you include a FORM in your web page, with the ACTION /cgi-bin/nph-redir.cgi. The form should have a field, usually a SELECT, with the name dest. The value of this field is the URL to which you wish to be redirected:
<FORM ACTION="/cgi-bin/nph-redir.cgi" METHOD="POST">
Destination URL?
   <SELECT NAME="dest">
   <OPTION VALUE="http://www.yahoo.com">Yahoo!
   <OPTION VALUE="http://www.netscape.com">Netscape
   <OPTION VALUE="http://www.cnet.com">c|net
   <OPTION VALUE="http://www.microsoft.com">Microsoft
   </SELECT>
<INPUT TYPE="SUBMIT" VALUE="Redirect Me!">
</FORM>
The above form will look as follows:
Destination URL?
By clicking on the pull-down list you can select a site. By then clicking on the submit ("Redirect Me!") button, you will be taken to that site.

If you are redirecting to a frameset, you can select a particular frame by putting its name in a field with the name target. An example of redirecting a user to Yahoo, in a frame called main, would look like this:

<form action="/cgi-bin/nph-redir.cgi" method="POST">
   <input type="HIDDEN" name="target" value="main">
   <input type="HIDDEN" name="dest"   value="http://www.yahoo.com">
   <input type="SUBMIT" value="Click Here To Visit Yahoo">
</form>

About nph-redir

nph-redir was developed by Jeff Carnahan, <jeffc@terminalp.com>.


© 1998, The University of Western Ontario. Permission is granted to copy in whole or in part provided that due credit is given to the authors, the Division of Information Technology Services, and The University of Western Ontario.

ITS HelpDesk<helpdesk@uwo.ca>
Last Update: April 21, 1998
Last Reviewed: August 13, 2007
URL: http://www.uwo.ca/its/doc/hdi/web/redirect.html