我正在尝试用密码保护子域及其所有子目录和文件,但我对此事的了解非常有限,我该怎么做?
I am trying to password protect a subdomain and all of it's subdirectories and files, but my knowledge on the matter is very limited, how can I go about doing that?
推荐答案这是一个简单的两步过程
It's a simple two step process
在你的 .htaccess 中
In your .htaccess put
AuthType Basic AuthName "restricted area" AuthUserFile /path/to/the/directory/you/are/protecting/.htpasswd require valid-user使用 www.htaccesstools/htpasswd-generator/ 或命令生成密码的行并将其放入 .htpasswd
use www.htaccesstools/htpasswd-generator/ or command line to generate password and put it in the .htpasswd
注意 1:如果您使用的是 cPanel,则应在安全部分密码保护目录"中进行配置
Note 1: If you are using cPanel you should configure in the security section "Password Protect Directories"
如果这不起作用,那么您可能需要对 http.conf中的 .htaccess(或至少以前的)目录执行 AllowOverride Allstrong> 然后是 apache 重启
If this didn't work then propably you need to do a AllowOverride All to the directory of the .htaccess (or atleast to previous ones) in http.conf followed by a apache restart
<Directory /path/to/the/directory/of/htaccess> Options Indexes FollowSymLinks MultiViews AllowOverride All </Directory>更多推荐
使用 .htaccess 保护目录及其所有子文件夹的密码
发布评论