![](/img/trans.png)
[英]Protecting folder using .htpasswd, but allowing php download while protecting password
[英]Protecting Sub folder using .htaccess and .htpasswd in PHP/Html
在我的网站中有子文件夹,因此我尝试使用.htaccess
和.htpasswd
保护该文件夹文件。
根文件夹
根文件
子文件夹
子文件夹文件
.htaccess
.htpasswd
-根文件
.htaccess代码如下所示
AuthType Basic
AuthName "My Protected Area"
AuthUserFile ./.htpasswd
Require valid-user
.htpasswd代码如下所示
test:pass@word1
当我输入http://10.10.10.11/website/subfolder/test.html时 ,提示输入密码,但我输入了它,但抛出错误。 见下图。
.htaccess
AuthType Basic
AuthName "restricted area"
AuthUserFile ./.htpasswd
require valid-user
如果您不想使用在线密码生成器,则可以使用openssl
openssl passwd -apr1 pass@word1
然后将生成的密码输入.htpasswd,格式为:
用户名:示例:
.htpasswd
username:$apr1$h81U4v3.$8Msypa0Kx2hQ/C0948BuV1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.