我想用一个设置用mod_digest保护多个目录。
目前我有 /etc/apache2/conf.a/mod-digest_realm-protected.conf
AuthType Digest
AuthName "protected"
AuthDigestDomain /adminer/ /school-project/
AuthDigestNonceLifetime 300
AuthDigestProvider file
AuthUserFile /etc/apache2/.digest
Require valid-user
并在 / etc / apache / sites-available / default
中<Directory /var/www/adminer/>
Include /etc/apache2/conf.a/mod-digest_realm-protected.conf
</Directory>
<Directory /var/www/school-project/>
Include /etc/apache2/conf.a/mod-digest_realm-protected.conf
</Directory>
有没有办法在单个配置文件中设置此设置?我试过这样的事情
<Directory /var/www/(adminer/school-project)/>
... auth_digest settings
</Directory>
但它不起作用。
答案 0 :(得分:9)
试试这个
<Directory /var/www/>
... auth_digest settings
</Directory>
正则表达式可以与Directory指令一起使用 http://httpd.apache.org/docs/current/en/mod/core.html#directory
如果您只想保护其中一些,我认为这应该有效。
<Directory ~ "(adminer|school-project)"/>
... auth_digest settings
</Directory>
答案 1 :(得分:0)
DirectoryMatch也可以
<DirectoryMatch ^/var/www/(adminer|school-project)>
...
</DirectoryMatch>