gpt4 book ai didi

.htaccess - 域特定的 htpasswd 条件

转载 作者:行者123 更新时间:2023-12-02 22:46:03 27 4
gpt4 key购买 nike

我正在使用通配符 DNS 系统,该系统通过单个 Web 应用程序路由所有子域,并根据 URL 的第一部分(X.domain.com,其中 X 是用户名)设置用户 ID。

我现在想要编辑我的 htaccess 文件,以针对特定域使用 htpasswd 启用条件 httpauth。例如如果 url = password.domain.com 则启用 httpauth。

我确信这是可能的,但对 htaccess 的了解有限。

最佳答案

您可以使用SetEnvIf ,这是来自 this post 的片段作者:汤姆·施利克。

#allows a single uri through the .htaccess password protection
SetEnvIf Request_URI "/testing_uri$" test_uri

#allows everything if its on a certain host
SetEnvIf HOST "^testing.yoursite.com" testing_url
SetEnvIf HOST "^yoursite.com" live_url
Order Deny,Allow

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/your/.htpasswd
AuthGroupFile /
Require valid-user

#Allow valid-user
Deny from all
Allow from env=test_uri
Allow from env=testing_url
Allow from env=live_url
Satisfy any

关于.htaccess - 域特定的 htpasswd 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2386182/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com