Solved

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

Posted on 2004-09-29
7
245 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

932 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

12 Experts available now in Live!

Get 1:1 Help Now