php - 如何使用 PHP 在 URL 中传递 URL(作为 GET 参数)?

标签 php apache url parameters get

我在将 URL 作为 GET 参数传递时遇到了一些问题。当我尝试访问时:

http://www.linkebuy.com.br/linkebuy/parceiro?url=http%3A%2F%2Fwww.google.com

我收到以下消息:

Unexpected error.

但是,如果我去:

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/

相关文章:

python - 控制 Flask 应用程序中的 URL 顺序

Javascript 网址管理

php - Volley : How to extract JSONObject from String Response? 这可能吗?

php - 如何使用假定的 col 值订购 mysql varchar 字段?

ruby-on-rails - 我在apache中使用乘客的rails时遇到403错误

php - 如何安装已安装但缺少依赖项 php-common 的 php-mbstring?

php - 散列或加密要在 url 中发送的变量

php - 我们可以在客户端计算机上存储数据库吗?

php - codeigniter 如何为 Controller 类和方法设置路由?

python - 通过 REST 将 Swift 数据发送到服务器并执行 Python 代码