Solved

how do i redirect using cgi on a windows server?  easy question, lots of points!

Posted on 2004-09-29
7
250 Views
Last Modified: 2013-12-25
I am programming on a windows server.

We have to field a request to http://www.mydomain.com/car.cgi?make=honda&year=1999

I just want to redirect the request with parameters to a .aspx page:
http://www.mydomain.com/car.aspx?make=honda&year=1999

What code could I put into car.cgi to redirect to car.aspx?
0
Comment
Question by:wilbur88
  • 3
  • 2
  • 2
7 Comments
 
LVL 15

Expert Comment

by:periwinkle
ID: 12185355

I think it would be something like:

use CGI qw(:standard);
my $passparms=$ENV{'PATH_INFO'};
print(redirect(qq(http://www.mydomain.com/car.aspx$passparams)));
0
 

Author Comment

by:wilbur88
ID: 12185681
I tried it and I just get on my page:

Status: 302 Moved Location: http://www.mydomain.com/car.aspx 
0
 

Author Comment

by:wilbur88
ID: 12186656
I have tried many other approaches too, from browsing through past solutions on experts exchange.  They all just print in the browser's window the url that I'm trying to go to!
Some of the other approaches I've tried:

print("Location:www.experts-exchange.com");

$query = new CGI;
print $query->redirect('http://www.mydomain.com/car.aspx' );

print "Content-type: text/html\n";
$location"http://www.mydomain.com/car.aspx";
print "Location: $location\n\n";

It doesn't seem like I'm even close!
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 5

Accepted Solution

by:
ITcrow earned 500 total points
ID: 12187093

Just put the following print statement in your CGI ( perl script ) and you will be fine:
Eg.
=======================================================
print qq~
<script>
window.location.replace("http://www.mydomain.com/car.aspx");
</script>
~;
=======================================================

And if you want to pass with arguments, you could use $ENV{'QUERY_STRING'}
Eg.
=======================================================
print qq~
<script>
window.location.replace("http://www.mydomain.com/car.aspx?$ENV{'QUERY_STRING'}");
</script>
~;
=======================================================
0
 

Author Comment

by:wilbur88
ID: 12189753
Yes, ITCrow!  and the 2nd part worked great for parameters as well.  Thanks so much-  Have a wonderful day-
0
 
LVL 15

Expert Comment

by:periwinkle
ID: 12189857
D'oh - clearly the cold medicine is affected my brain - thanks ITCrow - it would decidedly be QUERY_STRING, not PATH_INFO - lol.
0
 
LVL 5

Expert Comment

by:ITcrow
ID: 12192045
You are welcome wilbur88.

periwinkle,
while you were at cold_medicine_r_us, I jacked up my caffeine intake.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question