如何在 lighttpd 中为除一个目录之外的所有目录启用 http 身份验证?

如何在 lighttpd 中为除一个目录之外的所有目录启用 http 身份验证?

我正在尝试验证对 webroot 中所有内容的访问权限 (/) 除了位于特定目录 (/directory/)并且我尝试了这两个选项但都无济于事:

$HTTP["url"] =~ "^(?!(/directory))" {
    auth.require = ( "" =>
            (
            "method" => "basic",
            "realm" => "auth to this area",
            "require" => "user=username"
            )
    )
}

$HTTP["url"] != "/directory" {
    auth.require = ( "" =>
            (
            "method" => "basic",
            "realm" => "auth to this area",
            "require" => "user=username"
            )
    )
}

答案1

尝试这个:

$HTTP["url"] !~ "^/directory" {
    auth.require = ( "" =>
            (
            "method" => "basic",
            "realm" => "auth to this area",
            "require" => "user=username"
            )
    )
}

相关内容