Curl 引用和重定向
我想用curl伪造引荐来源网址,并且当前代码工作正常:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.target-url.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.facebook.com/');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
$html = curl_exec($ch);
curl_close ( $ch );
echo $html;
我想解决的问题是,当我在浏览器中运行代码时,URL保持不变(在浏览器顶部输入URL的地方)。 因此,代码所在页面的 URL 保留在顶部。但我想要真正的重定向,就像 header('位置:') 命令。
你能帮忙吗?
I want to fake referrer with curl and current code is working fine:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.target-url.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.facebook.com/');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
$html = curl_exec($ch);
curl_close ( $ch );
echo $html;
Problem that I want to solve is that when I run code URL in browser stay the same (in top of browser where you enter URL).
So URL of page where is code stay on top. But I would like to have real redirect like with
header( 'Location: ') command.
Can you help with this ?
如果您想要真正的重定向,那么只需在完成您想做的任何事情后使用 header('Location: ' . $url) 命令即可。
出于安全原因,您不能将另一个 URL 放入地址栏中。
如果可以的话,黑客会像现在一样向您发送垃圾邮件,发送看似真实的虚假电子邮件。然后,如果您点击他们的链接,看起来就像您在真实的网站(例如银行)上一样,当您输入它们时,他们会窃取您的用户名和密码。他们已经为不知情的人这样做了,但如果你可以按照你的要求去做,问题就会变得更糟。
If you would like a real redirect, then just use the header('Location: ' . $url) command after you've done whatever you want to do.
You cannot put another url into the address bar for security reasons.
If you could, hackers would spam you with emails as they do now with fake emails that look real. Then if you followed their links it would look like you were on the real site (such as a bank) and they would steal your username and password when you entered them. They already do this for people that are unaware, but it would make the problem even worse if you could do what you requested.