创建 htpasswd 并编辑 htaccess 后出现 500 错误

bac*_*ord 2 .htaccess .htpasswd apache-2.2

我刚刚编辑了.htaccess文件以包括:

AuthType Basic
AuthName "My Protected Area"
AuthUserFile /home/path/to/public_html/
Require valid-user
Run Code Online (Sandbox Code Playgroud)

然后我.htpasswd通过htpasswd命令创建了一个文件。我已启用模块:LoadModule authn_file_module modules/mod_authn_file.so在 Apache 配置中。

现在,当我加载页面时,出现 500 错误,Apache 日志显示:

配置错误:无法检查用户。没有用户文件?:/

lar*_*sks 5

AuthUserFile命令是由所提供的mod_authn_file模块。确保您的 Apache 配置包含以下内容:

LoadModule authn_file_module modules/mod_authn_file.so
Run Code Online (Sandbox Code Playgroud)

这需要进入主服务器配置,而不是.htaccess文件中。如果您无权访问主服务器配置,则需要联系您的本地管理员。