Answer the question
In order to leave comments, you need to log in
How can I get all server response codes when working with cURL?
I send a request to the server using php and cURL, but I can't intercept if there was a redirect with a 301 code to another page. curl_getinfo($ch,CURLINFO_HTTP_CODE);
This code returns only the last received HTTP code.
When using this code, all headers are returned, but along with the web page. curl_setopt($ch, CURLOPT_HEADER, 1);
Is it possible to somehow get this data separately without sending extra requests?
Answer the question
In order to leave comments, you need to log in
A redirect is just another request anyway.
You can write your own redirect handler
. To do this, we
look at the headers, if necessary, we request a new page (and so on in the loop until victory)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question