密码保护的子文件夹使用的.htaccess的目录和所有 [英] Password protecting a directory and all of it's subfolders using .htaccess
问题描述
我想密码保护的子域,它的所有子目录和文件,但我对此事的了解是非常有限的,我怎么能去这样做?
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
使用 http://www.htaccesstools.com/htpasswd-generator/ 或命令在线生成密码 并把它放在htpasswd的
use http://www.htaccesstools.com/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"
编辑:如果这没有工作,那么propably你需要做一个的AllowOverride全部
到的.htaccess的目录(或至少为previous的)在的http.conf 接着是阿帕奇重启
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的目录和所有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!