0
我试图实现一个头响应跟随recursevely头重定向。我已经实现了对第一个请求正确工作的以下内容,但是如果在头中找到位置重定向,则get_headers不会为重定向的位置返回任何结果。我想显示每个头申请的头。PHP get_headers递归
这就是我所做的。
function redirectURL($domain) {
$newLocation = '';
$domain = str_replace("\r", "", $domain);
$headers=get_headers($domain);
echo "<ul class='list-group' >";
print "<li class='list-group-item'>".$domain. "</li>";
foreach($headers as $k=>$v){
print "<li class='list-group-item'>".$k . ": " . $v . "</li>";
if(strstr($v, 'Location')){
$location = explode(":",$v);
$newLocation = $location[1].":".$location[2];
}
}
echo "</ul>";
if($newLocation != $domainName && $newLocation != ''){
redirectURL($newLocation);
}
unset($headers);
return true;
}
任何想法?我有一个在线实现...如果需要看到一个工作代码。 谢谢