Solved

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

Posted on 2004-09-29
7
244 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
Comment Utility

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
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 5

Accepted Solution

by:
ITcrow earned 500 total points
Comment Utility

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
Comment Utility
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
Comment Utility
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
Comment Utility
You are welcome wilbur88.

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now