代码在.htaccess文件后面:
AuthType Basic
AuthName "restricted area"
AuthUserFile ".htpasswd"
require valid-user代码在.htpasswd文件后面:
user121:$apr1$bVI1xobF$2ius9YiPaElsFDjD2DK5/0我使用正确的凭据登录,这是我每次登录时得到的信息:
Server error!
The server encountered an internal error and was unable to complete your request.
Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500更新:
Apache错误日志:
[Fri Jun 06 20:42:30.503554 2014] [authn_file:error] [pid 7536:tid 1760] (OS 2)
The system cannot find the file specified. : [client ::1:58747] AH01620: Could
not open password file: C:/xampp/apache/.htpasswd, referer:
http://localhost/manage/articles/我不能将文件放在我的the主机上的xampp/apache文件夹中?
发布于 2014-06-06 09:52:19
错误日志显示您使用了.htpasswd文件的错误路径:
无法打开密码文件:c:/xampp/apache/..htpasswd
这表明它不在C:/xampp/apache中。确保在.htaccess文件中使用正确的路径。例如,如果您的.htpasswd位于C:/xampp/apache/htdocs/myproject/..htpasswd下面,请将其设置为这样。
AuthUserFile C:/xampp/apache/htdocs/myproject/.htpasswd(虽然最好不要将.htpasswd放在htdocs/httpdocs中,但我只是使用这个路径作为示例。)
如果您确信路径是正确的,因为您似乎处于中,请确保该文件实际上名为.htpasswd。Windows无法从资源管理器(它禁止创建一个“仅扩展名”文件)执行此操作,您必须使用基于命令行的工具来完成此操作。如果您在记事本或其他文件中创建了.htpasswd,那么该文件现在很可能实际上称为.htpasswd.txt,请使用命令行将其重命名为.htpasswd:
C:\> cd C:\xampp\apache
C:\xampp\apache> move .htpasswd.txt .htpasswd发布于 2016-06-10 04:11:25
我用的是Mac,这个对我有用:
/Applications/XAMPP/xamppfiles/bin/htpasswd -cb /Applications/XAMPP/xamppfiles/.htpasswd admin passwordhttps://stackoverflow.com/questions/24078703
复制相似问题