The curl_getinfo function returns a large amount of metadata about the result of the HTTP request. However, for some reason it doesn't contain the information I currently want, which is the target URL if the request returns an HTTP redirect code.
I did not use CURLOPT_FOLLOWLOCATION because I wanted to handle specific redirect codes as special cases.
If cURL can track redirects, why can't it tell me what they redirect to when it doesn't?
Of course, I can set the CURLOPT_HEADER flag and select the Location header. But is there a more efficient way?
You can simply use this: (CURLINFO_REDIRECT_URL)
As you mentioned, disable CURLOPT_FOLLOWLOCATION option (before execution) and place my code after execution.
refer to