views:

34

answers:

1

Hi there, I am trying to pass a link within another in such a way :

http://www.1st_site.com/?u=http://www.2nd_site.com/?parameter1=xyz

I think what the problem is , parameter1=xyz is passed as a parameter for 1st_site

is there anyway to avoid that?

+2  A: 

You need to URL-encode the entire URL which is represented as query parameter value, else it will be interpreted as part of the request URL, thus this part: http://www.2nd_site.com/?parameter1=xyz.

It's unclear what programming language you're using, but most of decent webbased languages provides functions/methods/classes to achieve this, e.g. URLEncoder in Java, or c:url and c:param in JSP/JSTL, urlencode() in PHP and escape() in JavaScript.

Here's at least an online URL encoder: http://meyerweb.com/eric/tools/dencoder/. If you input http://www.2nd_site.com/?parameter1=xyz, you should get http%3A%2F%2Fwww.2nd_site.com%2F%3Fparameter1%3Dxyz back so the request URL should effectively end up in:

http://www.1st_site.com/?u=http%3A%2F%2Fwww.2nd_site.com%2F%3Fparameter1%3Dxyz

BalusC
thank you for your help. I am using php so I do encode it using urlencode.the reason for trying this mess is to get facebook share to recognize a link with parameters in it....which it seems to dislike...I did try to encode the url but that didnt seem to do it...any suggestions?
salmane