虚拟子目录上的Apache 2.4 AuthType none

时间:2015-07-17 22:04:14

标签: apache authentication location subdirectory apache2.4

除了单个虚拟目录之外,我需要整个站点需要auth。我的配置文件中有以下内容:

<VirtualHost *:80>
    <Location />
            AuthType Basic
            AuthName "protected site authentication required."
            AuthUserFile /home/me/.htpasswd
            Require valid-user
    </Location>

    <Location /foo>
            AuthType None
            Require all granted
    </Location>
</VirtualHost>

为什么这不起作用?我只想要除了/ foo位置之外的所有内容都要求auth。

1 个答案:

答案 0 :(得分:0)

围绕它有很多方法。最简单的,也可能是最讨厌的一个,就是用LocationMatch替换Location并使用负向前瞻,这基本上表示&#34;对所有不以&#34; / foo(/)&#34开头的事情做认证;:

public void PopDDL()
{
    FORM1.SelectCommand = "SELECT CompanyName FROM Company ORDER BY CASE WHEN CompanyName='Select' THEN 0 ELSE 1 END;"
    ddlSource.DataSourceID = "FORM1";
    ddlSource.DataTextField = "CompanyName";
    ddlSource.DataValueField = "CompanyName";
    ddlSource.DataBind();
    foreach (ListItem itm in ddlSource.Items) {
        if (itm.Value == "Select") {
            itm.Attributes.Add("disabled", "disabled");
        }
    }
}

protected void Page_Load(object sender, System.EventArgs e)
{
    PopDDL();
}