1$ch = curl_init();
2curl_setopt($ch, CURLOPT_URL, $url);
3curl_setopt($ch, CURLOPT_HEADER, TRUE);
4curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
5curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
6$a = curl_exec($ch);
7if(preg_match('#Location: (.*)#', $a, $r))
8 $l = trim($r[1]);