我需要限制访问我的Apache网络服务器上/sites/default/files/pdf/
中存储的所有文件。我试过跟FilesMatch
表达式,但这不起作用。
<FilesMatch "sites/default/files/pdf">
AuthName "myauth"
AuthBasicProvider ldap
AuthType Basic
AuthLDAPURL ....
AuthLDAPBindDN ....
AuthLDAPBindPassword ...
Require valid-user
</FilesMatch>
即使匹配特定文件名也不起作用(<FilesMatch "sites/default/files/pdf/myfile\.pdf">
)。我错过了什么吗?
答案 0 :(得分:1)
尝试Directory标记(如果是URL而不是文件路径,则使用Location标记)。您可以查看Apache文档,但Directory标记用于引用文件系统,而Location用于URL。如果多个URL /符号链接指向同一目录,但语法和基本功能相同,则存在差异。不要忘记允许/拒绝
<Directory /sites/default/files/pdf>
Order Deny, Allow
Deny from all
AuthName "myauth"
AuthBasicProvider ldap
AuthType Basic
AuthLDAPURL ....
AuthLDAPBindDN ....
AuthLDAPBindPassword ...
Require valid-user
</Directory>
OR
<Location /sites/default/files/pdf>
Order Deny, Allow
Deny from all
AuthName "myauth"
AuthBasicProvider ldap
AuthType Basic
AuthLDAPURL ....
AuthLDAPBindDN ....
AuthLDAPBindPassword ...
Require valid-user
</Location>