Home > php教程 > php手册 > body text

htaccess禁止指定后缀文件下载/扫描

WBOY
Release: 2016-06-07 11:42:07
Original
1201 people have browsed it

最近看到好多世界各地的IP批量扫描我站压缩文件,虽然这些文件实际并不存在,但对于下载站来说,禁止某些类型文件的下载是非常有用的。或者说,从根本上禁止网站备份文件如SQL文件被下载,同样是非常有用的!
我的方法有2个前提:
一、使用的是APACHE服务器,其他服务器我也不知道要怎么写;
二、开启了mod_rewrite模式。
满足这两个条件,再在根目录下的.htaccess文件中写入以下代码:<filesmatch><br> Order allow,deny<br> deny from all<br> </filesmatch>注意不要写在里面。
上面例举了常用的压缩包格式,当然看自己需要,可以添加mp3|mp4等等,这样设置好后,无论在网站哪个目录访问带以上后缀的文件,都将返回403错误。

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!