Solved

Passing query strings within a query string

Posted on 1998-07-19
2
150 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
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…

773 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