按照重定向与curl在php [英] follow redirects with curl in php

查看:95
本文介绍了按照重定向与curl在php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道使用cURL可以看到目标网址,将cURL指向具有CURLOPT_FOLLOWLOCATION = true的网址。

I know that using cURL i can see the destination URL, pointing cURL to URL having CURLOPT_FOLLOWLOCATION = true.

示例:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "www.example1.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
$result = curl_exec($ch);
$info = curl_getinfo($ch); //Some information on the fetch
curl_close($ch);

$ info将具有最终目标的网址,可以是www.example2.com。
我希望我上面的理解是正确的。如果没有,请让我知道。

$info will have the url of the final destination which can be www.example2.com. I hope my above understanding is correct. Please let me know if not!.

我的主要问题是,什么类型的重定向cURL将能够知道?
Apache重定向,javascript重定向,表单提交重定向,元刷新重定向?

My main question is, what all type of redirection cURL will be able to know? Apache redirect, javascript redirects, form submition redirects, meta-refresh redirects!?

更新
感谢您的answeres @ceejayoz和@Josso。所以有一种方法可以通过php跟踪所有的重定向程序?

update Thanks for your answeres @ceejayoz and @Josso. So is there a way by which I can follow all the redirect programatically through php?

推荐答案

cURL不会遵循JS或元标记重新导向。

cURL will not follow JS or meta tag redirects.

这篇关于按照重定向与curl在php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆