2013-03-06 66 views
0

这对我很长一段时间工作,突然它停止工作。 我在同一个文件夹的.htaccess和htpasswd的(用户)和下面是index.php文件php auth用户重定向标题位置

<? 
if(isset($_SERVER['PHP_AUTH_USER'])) { 
header("Location: http://website.com/users/".$_SERVER['PHP_AUTH_USER']); 
    } 
else header("Location: http://website.com/failed_login"); 
?> 
+0

你能在什么停止工作更精确? – Oli 2013-03-06 11:15:39

+0

它给你什么错误..? – 2013-03-06 11:15:44

+0

它仍然要求用户和密码 - 但是,如果我点击取消或如果我输入正确的信息,它会重定向到http://website.com/failed_login。 – user2139617 2013-03-06 11:26:31

回答

0

试试这个

<?php 
if(isset($_SERVER['PHP_AUTH_USER'])) { 
    header("Location: http://website.com/users/".$_SERVER['PHP_AUTH_USER']); 
} 
else { 
    header("Location: http://website.com/failed_login"); 
} 
?> 
+0

没有诀窍:( – user2139617 2013-03-06 11:19:15

+0

当您通过复制问题中的代码发布答案时,您应该对代码中所做的更改发表评论。 – 2013-03-06 11:20:47