服务器错误,当我使用.htaccess时出现此错误消息的原因

0 html php .htaccess

当我使用以下代码在名为admin的文件夹中使用.htaccess文件时

AuthName "Alertme"
AuthType Basic
AuthUserFile /mobs/.htpasswd
require valid-user 
Run Code Online (Sandbox Code Playgroud)

和.htpasswd文件,包含以下代码

rajasekar:66Acdia7gE1to
Run Code Online (Sandbox Code Playgroud)

访问文件夹内的文件时,它会出现服务器错误,服务器遇到内部错误,无法完成您的请求

为什么会发生这种情况.帮我

Mar*_*c B 6

很可能你的Apache配置现在允许在该目录和/或位置的.htaccess中使用Auth*指令.您可以检查为什么要查找该主机的error_log.会有一条看起来如下的线:

[Wed Dec 02 22:13:14 2009] [alert] [client x.x.x.x] /path/leading/to/.htaccess: AuthName not allowed here
Run Code Online (Sandbox Code Playgroud)

对于尝试访问该特定服务器/目录的任何客户端,此错误将显示为"500 Internal Server"错误.

您需要添加"AllowOverride AuthConfig",以便Apache接受.htaccess中的Auth指令.详情这里在Apache文档.