Php 浏览器中的.htaccess中没有登录提示

Php 浏览器中的.htaccess中没有登录提示,php,apache,.htaccess,httpd.conf,Php,Apache,.htaccess,Httpd.conf,我正在尝试使用.htaccess保护目录(/var/www/html/user)。该目录基本上具有index.php,它呈现如下html页面: <?php $login=$_SERVER['USER']; if(isset($login)) { // Output HTML content } else { echo " <html> <body> <center> User not recognized! </center> &l

我正在尝试使用.htaccess保护目录(/var/www/html/user)。该目录基本上具有index.php,它呈现如下html页面:

<?php    
$login=$_SERVER['USER'];

if(isset($login)) {
// Output HTML content
}
else {
echo "
<html>
<body>
<center>
User not recognized!
</center>
</body>
</html>
";
}
?>

我的.htaccess文件是:

AuthName "IT web"
AuthType Basic
AuthUserFile /remote/wwwin/LDAP_DB/dir-user-passwd
<Files index.php>
require valid-user
</Files>
AuthName“IT网站”
AuthType Basic
AuthUserFile/remote/wwwin/LDAP\u DB/dir user passwd
需要有效用户
当我尝试从浏览器访问index.php时,我没有得到登录提示,并且显示else条件下的html(即,用户未识别!)

服务器版本:Apache/2.2.3

我还在httpd.conf文件中验证了

AccessFileName.htaccess

如果有人能帮我确定问题,我将不胜感激


干杯

您正在检查错误的$\u服务器变量。PHP中的HTTP基本身份验证数据进入
PHP\u auth\u USER
PHP\u auth\u PW
键,而不是
USER

参见此处的示例#1:


您是否检查了.htaccess使用是否已启用?为了提高效率,它通常是关闭的。e、 g.
AllowOverride all
Yes,已启用htaccess。我刚刚签入了httpd.conf文件:AllowOverride All
if (!isset($_SERVER['PHP_AUTH_USER'])) { ... not logged in ... }