用.htaccess 禁止某类文件被访问

发布于 2014-03-24  102 次阅读


转自http://www.yilufafa.net/htaccess-prevent-access-to-some-file-types.html

比如我是用php空间,上面根本就没有.asp .aspx .mdb文件的

查网站的日志的 就会发现很多扫这类文件的

估计是通过找漏洞搞的,,

将下面的代码添加到.htaccess文件并上传

<FilesMatch (.*)\.(asp|aspx|mdb)$>
 order allow,deny
 deny from all
 </FilesMatch>

其他类型的文件自己依葫芦画瓢

Drupal里面有这样的一段

<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
 Order allow,deny
 </FilesMatch>