RT, some Web servers are configured
404
Rule: Redirect to the current Web site
相对URL
That, in this case, may produce
无限重定向
The problem, then, in the use of
CURL
What should I do to solve this problem when I get the data?
Reply content:
RT, some Web server configured the 404
rule: Redirect to the current site 相对URL
, in this case, may produce 无限重定向
problems, then, when using the CURL
fetch data, how should the problem be solved?
1 if multiple redirects are required, set curl following (Curlopt_followlocation)
2 If multiple redirects are not received, set the maximum number of redirect
3 If you need to analyze yourself, then resolve the HTTP response yourself, making a decision
Do you want to limit the number of redirects or?
CURLOPT_MAXREDIRS
The parameter can limit//Specify the maximum number of HTTP redirects, which is used with curlopt_followlocation.
Document Address: http://php.net/manual/zh/function.curl-setopt.php
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);//最多重定向5次
Curl can automatically follow the 301, see https://github.com/leaps/httpclient/blob/master/src/Leaps/HttpClient/Adapter/Curl.php
314 lines have the relevant code.