使用 .htaccess 保护目录及其所有子文件夹的密码 [英] Password protecting a directory and all of it's subfolders using .htaccess

查看:34
本文介绍了使用 .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"

如果这不起作用,那么您可能需要对 http.confAllowOverride 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 保护目录及其所有子文件夹的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆