【问题标题】:Domain specific htpasswd conditions特定于域的 htpasswd 条件
【发布时间】:2011-01-24 01:52:16
【问题描述】:

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

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

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

【问题讨论】:

    标签: .htaccess dns .htpasswd


    【解决方案1】:

    您可以使用 SetEnvIf,这是来自 Tom Schlick 的 this post 的 sn-p。

    #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
    

    【讨论】:

    猜你喜欢
    • 2011-10-20
    • 1970-01-01
    • 2015-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    相关资源
    最近更新 更多