开发者

.htaccess: Deny from all

开发者 https://www.devze.com 2022-12-18 11:47 出处:网络
This is working: <Files *.fileext> Order Allow,Deny Deny from all </Files> This is not: <Files *.fileext|somedirectory>

This is working:

<Files *.fileext>
      Order Allow,Deny
      Deny from all
</Files>

This is not:

<Files *.fileext|somedirectory>
      Order Allow,Deny
   开发者_如何学运维   Deny from all
</Files>

Please help.


Files does not allow the use of regular expressions, but FilesMatch does, therefore it searches for a file with (something).fileext|somedirectory in the path, and this is not what you want to do. Your code will have to look like this:

<FilesMatch (\.fileext$|^somedirectory$)>
    Order Allow,Deny
    Deny from all
</FilesMatch>

see http://httpd.apache.org/docs/1.3/mod/core.html#files and http://httpd.apache.org/docs/1.3/mod/core.html#filesmatch


This can be slightly improved. There is no need for an order directive and the end of string syntax can be used just once.

<FilesMatch (\.fileext|^somedirectory)$>
    Deny from all
</FilesMatch>
0

精彩评论

暂无评论...
验证码 换一张
取 消