HTTP 基本身份验证排除单个文件

发布于 2024-09-26 12:39:06 字数 319 浏览 3 评论 0原文

我的 .htaccess 文件的一部分如下所示 - 这样

AuthUserFile /path/to/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user

做需要对整个目录及其下面的目录进行基本 HTTP 身份验证。但是,我在该根目录中有一个文件 thubservice.php,该文件不需要 HTTP 身份验证。

据我所知,我需要使用,但我无法找出匹配除给定文件之外的所有文件的模式。

Part of my .htaccess file looks like this-

AuthUserFile /path/to/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user

Doing that requires the Basic HTTP authentication for the entire directory and the directories below it as well. However, I have a single file within that root directory, thubservice.php, that should not require the HTTP authentication.

From what I have seen, I need to use <FilesMatch />, but I cannot figure out the pattern to match all but that given file.

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

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

发布评论

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

评论(2

流星番茄 2024-10-03 12:39:06
AuthUserFile /path/to/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user
<Files "thubservice.php">
    Satisfy Any
    Allow from all
</Files>
AuthUserFile /path/to/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user
<Files "thubservice.php">
    Satisfy Any
    Allow from all
</Files>
猫九 2024-10-03 12:39:06

对于Apache 2.4,您可能需要使用需要 代替:

<Files "thubservice.php">
    Require all granted
</Files>

在 2.2 中,基于客户端主机名、IP 地址和客户端请求的其他特征的访问控制是使用指令 Order、Allow、Deny 和 Satisfy 完成的。

在 2.4 中,此类访问控制的完成方式与其他授权检查相同,使用新模块 mod_authz_host。旧的访问控制习惯应该被新的身份验证机制所取代,尽管为了与旧配置兼容,提供了新模块 mod_access_compat。

With Apache 2.4 you may want to use Require instead:

<Files "thubservice.php">
    Require all granted
</Files>

In 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives Order, Allow, Deny, and Satisfy.

In 2.4, such access control is done in the same way as other authorization checks, using the new module mod_authz_host. The old access control idioms should be replaced by the new authentication mechanisms, although for compatibility with old configurations, the new module mod_access_compat is provided.

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