1

我有以下用于身份验证的代码,如果 url 不是 index.html,则显示身份验证表单

<files "(?!index.html)">
    AuthUserFile  C:/wamp/www/eyedream/trunk/www/.htpasswd
    AuthName "Please login"
    AuthType Basic
    Require valid-user
</files>

如果文件不是 index.html,如何指定,显示身份验证框?

4

1 回答 1

0

您不能在<Files>块内使用 Auth 指令,它必须在 a<Directory>或 .htaccess 文件中。您可以设置环境变量并用于Satisfy Any绕过某些请求的身份验证:

SetEnvIfNoCase Request_URI ^/index.html$ norequire_auth=true
SetEnvIfNoCase Request_URI ^/$ norequire_auth=true

# Auth stuff
AuthUserFile C:/wamp/www/eyedream/trunk/www/.htpasswd
AuthName "Please login"
AuthType Basic

# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the "require_auth" var is NOT set
Allow from env=norequire_auth
于 2012-08-23T18:50:13.320 回答