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

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?
wilbur88Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ITcrowConnect With a Mentor Commented:

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
 
periwinkleCommented:

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
 
wilbur88Author Commented:
I tried it and I just get on my page:

Status: 302 Moved Location: http://www.mydomain.com/car.aspx 
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
wilbur88Author Commented:
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
 
wilbur88Author Commented:
Yes, ITCrow!  and the 2nd part worked great for parameters as well.  Thanks so much-  Have a wonderful day-
0
 
periwinkleCommented:
D'oh - clearly the cold medicine is affected my brain - thanks ITCrow - it would decidedly be QUERY_STRING, not PATH_INFO - lol.
0
 
ITcrowCommented:
You are welcome wilbur88.

periwinkle,
while you were at cold_medicine_r_us, I jacked up my caffeine intake.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.