我正在使用php脚本重定向我的网站中的用户,它一直工作得很好,直到上个星期一,突然它可以正常工作,有时它重定向到另一个实例上的期望页面错误。为什么我的重定向工作是随机的
重定向URL
devaltrack.dailyusers.com/rd?track=130&go=www.bbc.co.uk
自带有时
请求的URL /www.bbc.co.uk错误在此服务器上找到。
当我深入挖掘它,我意识到,如果我键入go
值与http
,它会永远工作,没有它工作时有时无, 有谁能够给我什么怎么回事
重定向脚本
$redirect_page= '/rccp.php';
$trusted_domain = $_GET['go'];
$track_id = $_GET['track'];
$strsql = ("CALL select_whitelisturls($track_id)");
$result = mysql_query($strsql);
$row = mysql_fetch_array($result);
if($row==""){
redirect_cookie_user($redirect_page);
}
if($row["redirect"] == 1){
if (false === strpos($trusted_domain, '://')) {
$trusted_domain = 'http://' . $trusted_domain;
//$trusted_domain = strtolower($trusted_domain);
}
if ($i = strpos($trusted_domain, '/', strpos($trusted_domain, '//')+2)){
$trusted_domain = strtolower(substr($trusted_domain, 0, $i)). substr($trusted_domain, $i);
}else{
$trusted_domain = strtolower($trusted_domain);
}
$domainarray = explode("\n", $row['domainname']);
if ($domainarray[0] == null){
exit();
}
foreach ($domainarray as $value) {
if (false === strpos($value , '://')) {
$value = "http://".$value;
$value = strtolower($value);
}else
{
$value = strtolower($value);
}
$pos = strrpos($trusted_domain, $value);
$domain_string =parse_url($trusted_domain);
$value_string =parse_url($value);
if(($pos !== false) &&($pos == 0) && ($value_string['host'] == $domain_string['host'])){
if (isset($_COOKIE["id"])){
$_GET['id'] = $_COOKIE["id"];
$_GET['go'] = $trusted_domain;
header('Location: '.$redirect_page.'?'.http_build_query($_GET));
exit();
}else{
header('Location: '.$trusted_domain);
exit();
}
}
}
}else{
exit();
}
function redirect_cookie_user($redirect_page){
if (isset($_COOKIE["id"])){
$_GET['id'] = $_COOKIE["id"];
header('Location: '.$redirect_page.'?'.http_build_query($_GET));
}
else{
exit();
}
}
它被解释为本地URL路径,而不是URL,除非你写了一个包含协议前缀。 – mario 2014-11-25 08:01:18
如果你需要实现的帮助(假如它真的在你声称的之前工作),你将不得不显示上述代码。 – mario 2014-11-25 08:02:25
对不起,我的本地跟踪网址..等不及格编辑它.. – 2014-11-25 08:02:54