禁用特定重写位置的http auth

时间:2011-12-01 08:47:03

标签: apache mod-rewrite authentication

我需要设置apache到反向匹配/管理位置,这是由默认的drupal htacess文件重写的。只需要为不是/ admin / *

的所有内容请求http auth

到目前为止我已经尝试过了:     

   < LocationMatch "^/(?!admin)" >
AuthName "Members Only" AuthType Basic AuthBasicProvider file AuthUserFile /path/to/.htpasswd Require valid-user
< /LocationMatch >

1 个答案:

答案 0 :(得分:0)

你可以尝试使用SetEnvIf来检查/ admin的Request_URI,所以你应该得到这样的结果:

# Set an environment variable if requesting /admin
SetEnvIf Request_URI ^/admin/? DONT_NEED_AUTH=true

# Setup your auth mechanism
AuthName "Members Only"
AuthType Basic
AuthBasicProvider file
AuthUserFile /path/to/.htpasswd

# Set the allow/deny order
Order Deny,Allow

# Indicate that any of the following will satisfy the Deny/Allow
Satisfy any

# First off, deny from all
Deny from all

# Allow outright if this environment variable is set
Allow from env=DONT_NEED_AUTH

# or require a valid user
Require valid-user

如果你没有将它放在.htaccess文件中,你可能需要将它包装在相应的或标签中。