php – header(“Location:/”); redirect适用于localhost,但不
发布时间:2020-12-13 13:48:54  所属栏目:PHP教程  来源:网络整理 
            导读:if (condition){#lol. Some code here}else{ header("Location:/");//i'm trying to redirect to the root} 重定向在localhost上完美运行,但在远程服务器上运行不正常. 使用$_SERVER可能更好吗? 即使我选择与具有重定向的文件位于同一目录中的文件,此重定向
                
                
                
            | if (condition)
{
#lol. Some code here
}
else
{       
header("Location:/");//i'm trying to redirect to the root
}重定向在localhost上完美运行,但在远程服务器上运行不正常. 
 从 
 manual: 
  
  
  
 <?php
/* Redirect to a different page in the current directory that was requested */
$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']),'/');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
?>(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! | 
