如何通过参数传递URL,作为参数? [英] How to pass URL with parameter, as a parameter?
问题描述
我试图传递一个网址作为参数,但该网址也有参数。当然这些参数是重要的,必须传输和正确解释。
(是的,我知道,我可以在一个文件中一次点击跟踪并重定向,但在某些特定情况下,我只是不能:有时我需要传递任何带有参数作为参数的URL)
到目前为止,我已经使用URL重写:
http://example.com/redirect_to.php?site=site1 => http://example.com/redirect/site1/
..但这并不是很方便(太多的情况下我需要更多的灵活性)
我的猜测可能是哈希参数URL:
例如: http://example.com/myclicktrackingscript.php?来源=侧边栏$ url = REJREJ12333232rerereE
...但是如何恰当地反驳它?
谢谢
我从来没有使用过这种技术,有没有人有任何关于如何做的例子/ div class =h2_lin>解决方案
您应该只编码参数:
urlencode('http ://example.com/redirect_to.php?site = site1')
编码值将会: http%3A%2F%2Fexample.com%2Fredirect_to.php%3Fsite%3Dsite1
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
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
这篇关于如何通过参数传递URL,作为参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!