我正在尝试用密码保护子域及其所有子目录和文件,但我对此事的了解非常有限,我该如何做到这一点?
最佳答案
这是一个简单的两步过程
在你的 .htaccess 中放置
AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/the/directory/you/are/protecting/.htpasswd
require valid-user
使用http://www.htaccesstools.com/htpasswd-generator/或命令行生成密码 并将其放入 .htpasswd
注 1:如果您使用 cPanel,则应在安全部分“密码保护目录”中进行配置
编辑:如果这不起作用,那么您可能需要执行 AllowOverride All
到 http.conf 中的 .htaccess 目录(或至少到以前的目录),然后重新启动 apache
<Directory /path/to/the/directory/of/htaccess>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
关于.htaccess - 使用 .htaccess 密码保护目录及其所有子文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5229656/