Is it possible for PHP to take a URL, wait for the redirects to go through, and then fetch the url of the page it's on?
+4
A:
$cr = curl_init("http://example.com");
curl_setopt($cr, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cr, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($cr);
$info = curl_getinfo($cr);
echo "url=".$info["url"];
serg
2009-10-17 05:21:34
Also, to add serg's answer... you might want `curl_setopt($cr, CURLOPT_MAXREDIRS, 5);` to set the max number of redirects to allow.
brianreavis
2009-10-17 06:04:53