Skip to content
Advertisement

Curl, follow location but only get header of the new location?

I know that when I set CURLOPT_FOLLOWLOCATION to true, cURL will follow the Location header and redirect to new page. But is it possible only to get header of the new page without actually redirecting there? Or is it not possible?

Advertisement

Answer

No. You’d have to disable FOLLOWLOCATION, extract the redirect URL from the response, and then issue a new HEAD request with that URL.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement