禁止浏览.htaccess文件

不少黑客会攻击和利用.htaccess作网站跳转,因此保护好.htaccess文件尤其重要。apache

在apache的httpd.conf的配置文件中 默认是已经设置了禁止对.htaccess的访问,截取相关配置文件以下:测试

# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>网站

我经过:http://localhost/test/.htaccess,在本地默认访问个人.htacess文件出现:this

Forbidden

You don't have permission to access /test/.htaccess on this server.server

固然当apache没设这样的配置或者本身没权限更改配置文件时,你也能够手动在更改本身本地的.htacess文件,添加以下代码:io

<Files .htaccess>
order allow,deny
deny from all
</Files>event

这样的效果和上面同样。test

当把deny改为allow,代码改为以下:cli

<Files .htaccess>
order allow,deny
allow from all
</Files>配置

咱们的.htacess文件便可以被访问,固然这样是比较危险的,咱们本地只是作个测试。仍是赶快把allow改为deny吧。

相关文章
相关标签/搜索