0

I need to restrict access to all files stored in /sites/default/files/pdf/ on my Apache webserver. I have tried following FilesMatch expression, but that does not work.

<FilesMatch "sites/default/files/pdf">
AuthName "myauth"
AuthBasicProvider ldap
AuthType Basic
AuthLDAPURL ....
AuthLDAPBindDN ....
AuthLDAPBindPassword ...
Require valid-user
</FilesMatch>

Even matching for specific filename does not work (<FilesMatch "sites/default/files/pdf/myfile\.pdf">). Am I missing something?

4

1 回答 1

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>

或者

    <Location /sites/default/files/pdf>
     Order Deny, Allow
     Deny from all

     AuthName "myauth"
     AuthBasicProvider ldap
     AuthType Basic
     AuthLDAPURL ....
     AuthLDAPBindDN ....
     AuthLDAPBindPassword ...
     Require valid-user
    </Location>
于 2013-09-18T17:13:52.813 回答