I have a database of over 10,000 URL's, however every single one of them redirects to another URL. How can I request a URL and find out it's final destination in a path of (possibly) multiple redirects?
You can do it using the cURL functions:
$c = curl_init('http://original.url');
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_exec($c);
// Error checking here - see curl_error()
$newUrl = curl_getinfo($c, CURLINFO_EFFECTIVE_URL);
curl_close($c);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With