Apache设置禁止访问网站目录 您所在的位置:网站首页 网站目录文件夹大写怎么设置 Apache设置禁止访问网站目录

Apache设置禁止访问网站目录

2024-06-29 16:09| 来源: 网络整理| 查看: 265

Apache默认在当前目录下没有index.html入口就会显示网站根目录,让网站目录文件都暴露在外面,是一件非常危险的事,例如:数据库密码泄露,隐藏页面暴露等严重安全问题!

例如,访问米扑网站根目录: https://mimvp.com    会列出根目录

apache-setting-prohibit-access-to-the-site-directory

 

本文将详细介绍如何操作禁止显示apache网站根目录

进入apache的配置文件 httpd.conf 找到:

vim /etc/httpd/conf/httpd.conf

Options Indexes FollowSymLinks

修改为:

Options FollowSymLinks

修改后结果如下:

 #    Options None                         #    Options Indexes FollowSymLinks     Options FollowSymLinks

     AllowOverride All     Order allow,deny     Allow from all

其实就是将Indexes去掉,Indexes表示若当前目录没有index.html就会显示目录结构。

重启Apache服务器  /etc/init.d/httpd restart

再访问米扑网站,就没问题了: https://mimvp.com

 

1. 禁止访问某些文件/目录

增加Files选项来控制,比如要不允许访问 .inc 扩展名的文件,保护php类库:     Order allow,deny     Deny from all

禁止访问某些指定的目录:(可以用    来进行正则匹配)

     Order allow,deny     Deny from all

通过文件匹配来进行禁止,比如禁止所有针对图片的访问:

     Order allow,deny     Deny from all

针对URL相对路径的禁止访问:

     Order allow,deny     Deny from all

 

配置示例

## Possible values for the Options directive are “None”, “All”,# or any combination of:# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews## Note that “MultiViews” must be named *explicitly* — “Options All”# doesn’t give it to you.## The Options directive is both complicated and important. Please see# http://httpd.apache.org/docs/2.2/mod/core.html#options# for more information.# 就是这一行,只去掉indexes也可#Options Indexes FollowSymLinksOptions FollowSymLinks## AllowOverride controls what directives may be placed in .htaccess files.# It can be “All”, “None”, or any combination of the keywords:# Options FileInfo AuthConfig Limit#AllowOverride None## Controls who can get stuff from this server.#Order allow,denyAllow from all

建议默认情况下,设置APACHE禁止用户浏览目录内容。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有