Boi*_*lov 5 apache authentication mod-rewrite
我需要设置apache到反向匹配/管理位置,这是由默认的drupal htacess文件重写的.只需要对不是/ admin/*的所有内容请求http auth
到目前为止我试过这个:
< LocationMatch "^/(?!admin)" >
AuthName "Members Only" AuthType Basic AuthBasicProvider file AuthUserFile /path/to/.htpasswd Require valid-user
< /LocationMatch >
您可以尝试使用 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
Run Code Online (Sandbox Code Playgroud)
如果您不将其放入 .htaccess 文件中,则可能需要将其包装在适当的或标签中。