Curl 引用和重定向

发布于 11-29 16:12 字数 564 浏览 2 评论 0原文

我想用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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

朕就是辣么酷2024-12-06 16:12:01

如果您想要真正的重定向,那么只需在完成您想做的任何事情后使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文