研究了一下,发现还是可以转变的。
function getrealurl($url){
$header=get_headers($url,1);
if (strpos($header[0],'301')||strpos($header[0],'302')){
if(is_array($header['location'])){
return $header['location'][count($header['location'])-1];
}else{
return $header['location'];
}
}else{
return $url;
}
}例如下面这个例子: header('content-type:text/html;charset=utf-8');
function getrealurl($url){
$header=get_headers($url,1);
if (strpos($header[0],'301')||strpos($header[0],'302')){
if(is_array($header['location'])){
return $header['location'][count($header['location'])-1];
}else{
return $header['location'];
}
}else{
return $url;
}
}
$url='http://www.baidu.com/link?url=nuq4redikrtchpwqqxjptc_gsleurk6bb6wmcmzqalhes2luiv98oaikzjvjz8xx';
$url=getrealurl($url);
echo '真实的url为:'.$url;
