【发布时间】:2015-05-26 17:20:03
【问题描述】:
我正在尝试制作一个重定向 php 脚本,我希望该脚本检查链接是否存在,然后将用户重定向到该链接,如果它不存在,那么它将获得下一个链接,依此类推,但是由于某种原因无法正常工作,也许您可以为此提供一些帮助。
<?php
$URL = 'http://www.site1.com';
$URL = 'http://www.site2.com';
$URL = 'http://www.site3.com';
$handlerr = curl_init($URL);
curl_setopt($handlerr, CURLOPT_RETURNTRANSFER, TRUE);
$resp = curl_exec($handlerr);
$ht = curl_getinfo($handlerr, CURLINFO_HTTP_CODE);
if ($ht == '404')
{ echo "Sorry the website is down atm, please come back later!";}
else { header('Location: '. $URL);}
?>
【问题讨论】:
标签: php redirect curl url-redirection