我希望通过php点击计数器重定向链接
http://www.mymaza.com/songs/pakistani_pop/download/pakistan.php?id=168
此页面重定向到
http://sound5.mp3pk.com/pakistani/sajjad_ali/babia/babia1(www.songs.pk).mp3
我希望获得重定向的页面链接
然而,我试过其他方法似乎不容易
答案 0 :(得分:0)
您可以使用cURL
解析指定的网址:
function resolveURL($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$response = curl_exec($ch);
$resolved = curl_getinfo($ch);
return $resolved['url'];
}
用法:
echo resolveURL('http://example.com/someurl.php?foo=42')