简体   繁体   English

卷曲重定向不起作用。 我究竟做错了什么?

[英]Curl redirection not working. What am I doing wrong?

I want to redirect a specific page from my .in domain to my .com domain using curl and at the same time change the HTTP Referer to something else (blank). 我想使用curl将特定页面从.in域重定向到.com域,同时将HTTP Referer更改为其他名称(空白)。

I am using the following code : 我正在使用以下代码:

<?php 

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/random');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, '');
curl_exec($ch);
/*$html=curl_exec($ch); - tried this, but does not work.*/
curl_close($ch);

?>

The URL for the above script would be something like : http://www.example.in/random.php Upon navigating to the above URL where the script resides, I expect the client to be redirect to http://www.example.com/random . 对于上面的脚本的URL会是这样的: http://www.example.in/random.php在导航到脚本所在的URL之上,我预计客户将重定向到http://www.example.com/random All I get is a blank page, without any error or any other data and no redirection too. 我得到的是空白页,没有任何错误或任何其他数据,也没有重定向。

On executing the script form Firefox, Chrome, Safari or Opera, doesn't work. 在执行脚本形式时,Firefox,Chrome,Safari或Opera不起作用。 Basically, something in the script is wrong and I can't figure out what. 基本上,脚本中的某些内容是错误的,我无法弄清楚是什么。 I don't know much about Curl and this script was essentially pulled off from the Web. 我对Curl不太了解,该脚本实际上是从Web上提取的。

I could be wrong but isn't curl() for downloading files rather than redirection? 我可能是错的,但是不是curl()用于下载文件而不是用于重定向吗? I would use php to set the header to do a redirect. 我将使用php设置标头以进行重定向。

header("Location: www.mysite.com");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM