Click to See Complete Forum and Search --> : Server-Side Redirects


Death on Wheels
10-07-2000, 08:03 PM
The following Perl script should redirect the user to http://www.cerberos.org when called:


#!/usr/bin/perl

#Parses the form data
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}

#Prints appropriate header for page requested
if ($FORM{$NavBar} eq "blank"){
print "Location:http://www.cerberos.org\n\n";
}


Unfortunately, it's not.


------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!

stiles
10-07-2000, 08:14 PM
any reason your not using the really simple html solution to redirecting incoming trafic?

<meta http-equiv="REFRESH" content="2; url=http://www.cerberos.org">

that will give a 2 second pause before it's redirected to www.cerberos.org (http://www.cerberos.org)

Death on Wheels
10-07-2000, 08:27 PM
1) This script is called by a form which is used by a user to select their page.

2) Not all browsers support the REFRESH attribute of the META tag. Although I could create a page with a link, that would defeat the purpose of #1.

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!

klamath
10-07-2000, 11:39 PM
Why aren't you using CGI.pm ? The redirect() subroutine does exactly what you need. See `perldoc CGI` for more info.

------------------
- Klamath
Get my GnuPG Key Here (http://klamath.dyndns.org/mykey.asc)

Death on Wheels
10-08-2000, 12:09 AM
I simply choose not to.

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!

takshaka
10-08-2000, 04:09 PM
HTTP/1.0 and HTTP/1.1 are at odds on how to go about redirecting from a POST transaction. So are most browsers. Use a GET, or use some other method of redirection.