[英]CURL “failed to open stream: Redirection limit reached” works local but not on server
I have a script that works on my local machine, on a shared server, on web browser, but not on VPS . 我有一个脚本可以在本地计算机,共享服务器,Web浏览器上运行, 但不能在VPS上运行 。
I use CURL to download a webpage's HTML, for example this url: 我使用CURL下载网页的HTML,例如以下URL:
https://www.yes.co.il/content/YesChannelsHandler.ashx?action=GetDailyShowsByDayAndChannelCode&dayValue=0&dayPartByHalfHour=37&channelCode=YSAL
It fails with an error: 它失败并显示错误:
failed to open stream: Redirection limit reached
The VPS php version is: PHP 5.5.9-1ubuntu4.3 VPS php版本为: PHP 5.5.9-1ubuntu4.3
Any ideas how to solve this issue? 任何想法如何解决这个问题?
Thanks! 谢谢!
Your VPS has a different max redirection limit then the other environments. 您的VPS具有与其他环境不同的最大重定向限制。 You should be able to increase it using the cUrl PHP option CURLOPT_MAXREDIRS. 您应该能够使用cUrl PHP选项CURLOPT_MAXREDIRS来增加它。
Assuming you are using the resource name $ch: 假设您正在使用资源名称$ ch:
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
Your version works locally, but not on the server. 您的版本在本地运行,但不能在服务器上运行。 And, it seems that you are accessing https://. 并且,似乎您正在访问https://。 So, try with: 因此,尝试:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Also, find out how many redirection are happening, and if possible, give the last URL in the redirect. 另外,找出发生了多少重定向,并在可能的情况下提供重定向中的最后一个URL。
What about follow location setting? 追踪位置设定如何? Did you try? 你试过了吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.