11

我在将 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 进行编码。

编辑: 你问的代码......

在第一个视图中,链接在哪里(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
}

它包括视图lead-parceiro.php(在问题上方,我链接到此页面),其中头部包含:

<script type="text/javascript">
    setInterval(function(){ window.location = '<?php echo $url ?>'; },3000);
</script>
4

2 回答 2

7

如果您无法摆脱限制,您可以像这样将 url 分成两部分传递

http://www.linkebuy.com.br/linkebuy/parceiro?protocol=http&url=www.google.com

然后在您的代码上解析它以生成重定向的完整 url。

于 2013-03-06T18:07:17.393 回答
5

urlencode当您将任何内容作为 URL 参数传递时,您应该使用

于 2013-03-06T18:17:00.473 回答