使用 .htaccess 保护目录及其所有子文件夹的密码

编程入门 行业动态 更新时间:2024-10-09 02:25:51
本文介绍了使用 .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

使用 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 然后是 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 保护目录及其所有子文件夹的密码

本文发布于:2023-11-01 01:08:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547804.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   密码   目录   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!