Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass URL with parameter, as a parameter? [duplicate]

Tags:

php

get

I'm trying to pass a URL as a parameter, but that URL also has parameters. Of course these parameters are important and must be transmitted and properly interpreted.

For example : http://example.com/myclicktrackingscript.php?source=sidebar&url=http://example.com/redirect_to.php?site=site1

(yes I know, I could click track and redirect all at once in one file, but in some specific situations, I just can't : sometimes I need to pass whatever URL with parameters AS a parameter)

So far i've used URL rewriting : http://example.com/redirect_to.php?site=site1 => http://example.com/redirect/site1/

.. but that's not very handy (too many specific situations where I need more flexibility)

Is there a better way to do that ?

My guess is maybe hashing the parameter URL :

For example : http://example.com/myclicktrackingscript.php?source=sidebar$url=REJREJ12333232rerereE

... but how to "dehash" it properly ?

I've never used such technique, has anyone any examples / tips / advice about how to do so ?

Thanks

like image 546
Baptiste Avatar asked Nov 16 '25 08:11

Baptiste


1 Answers

You should just encode parameter:

urlencode('http://example.com/redirect_to.php?site=site1')

And encoded value will be: http%3A%2F%2Fexample.com%2Fredirect_to.php%3Fsite%3Dsite1

like image 71
Uriil Avatar answered Nov 17 '25 22:11

Uriil