[英]How to pass URL in URL (as GET parameter) using PHP?
我在將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>
如果你無法擺脫限制,你可以通過這兩個部分的URL傳遞
http://www.linkebuy.com.br/linkebuy/parceiro?protocol=http&url=www.google.com
然后在您的代碼上解析它以生成重定向的完整URL。
當您將任何內容作為URL參數傳遞時,您應該使用urlencode
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.