PHP trace redirection

I have a database with over 10,000 URLs, however each of them redirects to a different URL. How can I request a url and find out its final destination on a (possibly) multiple redirects path?

+3
source share
1 answer

You can do this using the cURL functions :

$c = curl_init('http://original.url');
curl_setopt(CURLOPT_FOLLOWLOCATION, true);
curl_exec($c);

// Error checking here - see curl_error()

$newUrl = curl_getinfo($c, CURLINFO_EFFECTIVE_URL);

curl_close($c);
+9
source

Source: https://habr.com/ru/post/1720437/


All Articles