我在将 URL 作为 GET 参数传递时遇到了一些问题。当我尝试访问时:
http://www.linkebuy.com.br/linkebuy/parceiro?url=http%3A%2F%2Fwww.google.com
我收到以下消息:
但是,如果我去:
http://www.linkebuy.com.br/linkebuy/parceiro?url=123
一切正常(它重定向到一个不存在的站点 - 123 - 当然,但它确实符合预期)。通过消除我可以说 url
参数有问题,但它是什么?
OBS:我正在使用 rawurlencode()
对 URL 进行编码。
编辑: 您询问的代码...
在第一个 View 中,链接位于 ( http://www.linkebuy.com.br/notebook/detalhe?id=5 ):
<!-- url() function just completes the right URL (production or development) -->
<a href="<?php echo url('linkebuy/parceiro/?url=' . rawurlencode($l->getUrl()), true) ?>" class="<?php echo $leadClass ?> oferta" target="_blank">
<?php echo $l->getNomeFantasia() ?>
</a>
单击链接时,链接会重定向到一个操作 (/linkebuy/parceiro
),其中会发生以下情况(基本上什么都没有,只是保留在框架中):
public function execute($request, $response) {
$response->addParameter('url', rawurldecode($request->getParameter('url', ''))); //This creates $url in the view
$response->setTemplate('site/linkebuy/lead-parceiro.php'); //Forwards to the view
}
它包括 View ,lead-parceiro.php
(上面的问题,我链接到这个页面),其中 head 包含:
<script type="text/javascript">
setInterval(function(){ window.location = '<?php echo $url ?>'; },3000);
</script>
最佳答案
如果你不能摆脱限制,你可以像这样分两部分传递 url
http://www.linkebuy.com.br/linkebuy/parceiro?protocol=http&url=www.google.com
然后在您的代码中解析它以生成重定向的完整 url。
关于php - 如何使用 PHP 在 URL 中传递 URL(作为 GET 参数)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15254112/