.htaccess 和文件夹保护 - 我应该在另一个文件夹中创建另一个 .htacess 文件吗?

发布于 2025-01-02 13:41:00 字数 691 浏览 2 评论 0原文

.htaccess 文件包含重写规则列表并且工作正常,

.htaccess 文件位于根目录中,

.htaccess 包含:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^index.php / [L,R=301]

如何密码-保护/secret文件夹?

我应该添加

AuthUserFile /secret/path/to/safedirectory/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic
require valid-user

到根目录中的 .htaccess 文件吗?就在上面的代码之后,还是在最开始?

或者,我必须在 /secret 文件夹中创建另一个 .htaccess 文件,并将 .htpasswd 放入 /secret/safedirectory< /em> 文件夹?

谢谢。

.htaccess file contains a list of rewrite rules and works fine,

.htaccess file is in the root directory,

.htaccess contains:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^index.php / [L,R=301]

How to password-protect a /secret folder?

Should I add

AuthUserFile /secret/path/to/safedirectory/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic
require valid-user

to .htaccess file that is in the root directory? Right after the code above, or at the very beginning?

Or, I have to create another .htaccess file in the /secret folder, and put .htpasswd into /secret/safedirectory folder?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山川志 2025-01-09 13:41:00

您是否将其放入秘密目录中的 .htaccess 中?

 AuthUserFile /path/to/safedirectory/.htpasswd
 AuthGroupFile /dev/null
 AuthName EnterPassword
 AuthType Basic
 require valid-user

您必须将 .htaccess 放在秘密目录中

Did you put this in the .htaccess in the secret directory?

 AuthUserFile /path/to/safedirectory/.htpasswd
 AuthGroupFile /dev/null
 AuthName EnterPassword
 AuthType Basic
 require valid-user

You have to put the .htaccess in the secret directory

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文