这样的需求还是很大的,比如说在获取Baidu的搜索结果的时候,得到的都是类似于 ‘http://www.baidu.com/link?url=j8G7nxXYa-asQ68krSIb9bv2A3shycPzQJD8BVUUPQu’ 这样的一个URL,需要经过一个/多个跳转,这时这样的功能就有作用了:
<?php
function getrealurl($url){
$header = get_headers($url, 1);
print_r($header);
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;
}
}
//echo getrealurl('http://ixyzero.com/');
echo getrealurl('http://www.baidu.com/link?url=j8G7nxXYa-asQ68krSIb9bv2A3shycPzQJD8BVUUPQu');
做个记录!
《“用PHP获取网页301/302跳转后的真实地址”》 有 1 条评论
open-redirect-scanner – 任意网址跳转漏洞扫描脚本
https://github.com/ak1t4/open-redirect-scanner