CURL is not following 301 Redirects, what do I need to do? CURL is not following 301 Redirects, what do I need to do? curl curl

CURL is not following 301 Redirects, what do I need to do?


In the PHP world, the option is named CURLOPT_FOLLOWLOCATION. I assume the constant names are standardized and come from the same header file, so this should work for you.

curl_easy_setopt(eh, CURLOPT_FOLLOWLOCATION, 1); 

(or whatever "boolean true" is in this context.)

Alternatively, when receiving a 30x status code, you can parse the Location header manually for the new address. Obviously though, the "follow location" option is much easier, as it doesn't require a second request.