Solved

Passing query strings within a query string

Posted on 1998-07-19
2
152 Views
Last Modified: 2013-12-25
/cgibin/redirect.cgi?url=http://www.digitalriver.com/dr/v2/ec_Main.Entry?SP=10007&SID=6370&CID=0

When I run the above script to redirect on link, the query string in the url to be redirected to seems to get cut off at the =. How can I solve this?
0
Comment
Question by:djschaper
2 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1830840
use urlencode to encode the querystring, for example with Javascript escape()
0
 
LVL 6

Accepted Solution

by:
alamo earned 50 total points
ID: 1830841
When you run a redirect like this, you can't use standard QUERY_STRING processing in your redirect script, because the query string in the redirected url has to be decoded at the final destination, not by you. If you urlencode the querystring your cgi has to decode and then reencode or information will be lost- it's quite tricky, and can easily fail. And it's unnecessary.

The easy way to do it is to change the url to:

/cgibin/redirect.cgi?http://www.digitalriver.com/dr/v2/ec_Main.Entry?SP=10007&SID=6370&CID=0

notice the url= part is gone. Now, in redirect.cgi don't do any QUERY_STRING processing at all, just do the redirect (shown in perl, if you are using something else the idea is the same):

print "Location: $ENV{QUERY_STRING}\n\n";

If you really must have additional fields encoded as part of your redirect url, either place them at the start of the QUERY_STRING and process them specially, or put them into PATH_INFO so they are separate.

Hope this helps!
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert MSI to MSM 1 76
excel file 5 76
Need to Modify a Script I found 5 108
Can I exclude specific directory with icacle command? 3 59
Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
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…
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

830 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