apache去掉目录浏览
apache去掉目录浏览
apache默认开启目录浏览的,这样大大降低了我们网站的安全,下面是关闭浏览目录:
要禁止 Apache 显示目录结构列表,只需将 Option 中的 Indexes 去掉即可。
比如我们看看一个目录的目录配置:
<Directory "D:/Apa/blabla">
Options Indexes FollowSymLinks #改为--> Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
你只需要将上面红色代码中的 Indexes 去掉,就可以禁止 Apache 显示该目录结构。用户就不会看到该目录下的文件和子目录列表了。
Indexes 的作用就是当该目录下没有 index.html 文件时,就显示目录结构,去掉 Indexes,Apache 就不会显示该目录的列表了。
第二种方法
解决办法:
1、编辑httpd.conf文件
vi ./conf/httpd.conf
找到如下内容:
......
<Directory "C:/Program Files/Apache2.2/htdocs">
#
# 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.
#
Options Indexes 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,deny
Allow from all
</Directory>
......
在Options Indexes FollowSymLinks在Indexes前面加上 - 符号。
即: Options -Indexes FollowSymLinks
【备注:在Indexes前,加 + 代表允许目录浏览;加 - 代表禁止目录浏览。】
这样的话就属于整个Apache禁止目录浏览了。
如果是在虚拟主机中,只要增加如下信息就行:
<Directory "D:\test">
Options -Indexes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
这样的话就禁止在test工程下进行目录浏览。
备注: 切记莫把“Allow from all”改成 “Deny from all”,否则,整个网站都不能被打开。
<Finished>
还有一种方法:
可以在根目录的 .htaccess 文件中输入
<Files *>
Options -Indexes
</Files>
复制代码
就可以阻止Apache 将目录结构列表出来。
apache去掉目录浏览的更多相关文章
- 关闭或者开启apache的目录浏览
为了安全或者方便需要关闭或者开启apache的目录浏览 关闭目录浏览 修改http.conf 文件 Options Indexes FollowSymLinks 改为 ...
- Apache索引目录浏览的学习笔记
在浏览一些镜像文件站的时候,会发现网站目录是可以浏览文件(夹)列表的.举两个例子:网易开源镜像:Ubuntu.只要 Web 服务器是基于 Apache 的网站都可以开启或禁止索引(目录浏览),那么如何 ...
- Nginx 和 Apache 开启目录浏览功能
1.Nginx 在相应项目的 Server 段中的 location 段中,添加 autoindex on.例如: server { listen ; server_name www.dee.prac ...
- nginx和apache配置目录浏览功能
今天工作需要,要给客户提供一个patch的下载地址,于是想用nginx的目录浏览功能来做,需要让客户看到指定一个目录下的文件列表,然后让他自己来选择该下载那个文件: 我们都知道在apache下可以配置 ...
- Ubuntu apache 禁止目录浏览
$ sudo vim /etc/apache2/sites-enabled/000-default 将Options后面Indexes前面加上"-"表示禁止目录浏览: <Di ...
- 关闭Apache的目录浏览功能
一.默认情况 默认情况下,Apache的配置文件C:\web\apache2.4\conf/httpd.conf中有如下参数: 引用 <Directory "/var/www/html ...
- mac上Apache修改目录浏览权限
sudo vim /etc/apache2/httpd.conf <Directory "/Library/WebServer/Documents"> # # Poss ...
- apache的目录浏览功能 列出的文件名不完整,能否修改设置
在httpd.conf 和 httpd-vhosts.conf中的 <Directory ????> </Directory>如下设置,重启apache即可: <Dir ...
- Apache开启目录浏览功能的正确姿势
部分代码是抄的网友的,哪儿抄的忘了,我是自己修改了点,并非我本人原创,觉得侵权联系我,立马删 在宝塔面板中,打开网站的设置,在配置文件那里添加如下内容 Directory "文件绝对路径&q ...
随机推荐
- ironic baremetal node status
参考: https://docs.openstack.org/ironic/latest/contributor/states.html https://docs.openstack.org/iron ...
- 2013 ACM/ICPC Asia Regional Changsha Online – C题 Color Representation Conversion (坑爹模拟题)
题意:给你三种颜色表示模式,RGB,HSV和HSL,实现任意模式之间两两转化. 1.最好别看题目中给的转化公式描述,我觉得叙述的一点也不清楚,看维基百科,把维基百科上的公式一句一句翻译过来就好 2.在 ...
- HS 光流法详解
前言 本文较为详细地介绍了一种经典的光流法 - HS 光流法. 光流法简介 当人的眼睛与被观察物体发生相对运动时,物体的影像在视网膜平面上形成一系列连续变化的图像,这一系列变化的图像信息不断 &quo ...
- InfluxDB数据备份和恢复方法,支持本地和远程备份
本文属于<InfluxDB系列教程>文章系列,该系列共包括以下 17 部分: InfluxDB学习之InfluxDB的基本概念 InfluxDB学习之InfluxDB的基本操作 Influ ...
- LeetCode -- Valid Parenthese
Question: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine i ...
- hdu 2993 斜率dp
思路:直接通过斜率优化进行求解. #include<iostream> #include<cstdio> #include<algorithm> #include& ...
- 将windows文本格式转换为UNIX格式
将windows文本格式转换为UNIX格式 1.使用sed命令来进行转换,如下: sed -e ’s,^M,,g’ textfile 其中^M的输入方法是Ctrl+V, Ctrl+M 对于批量文件的处 ...
- Educational Codeforces Round 57 (Rated for Div. 2) ABCDEF题解
题目总链接:https://codeforces.com/contest/1096 A. Find Divisible 题意: 给出l,r,在[l,r]里面找两个数x,y,使得y%x==0,保证有解. ...
- Python学习笔记(Django篇)——2、创建第一个django应用
在helloworld工程的基础上,我们准备创建第一个基于web的django应用,把这个应用名字命名为demo 首先,是如何创建这个应用包,当然第一选择我们可以进入到cmd中,执行如下命令 py ...
- 转:Java NIO(2)
java.nio包是Java在1.4之后增加的,用来提高I/O操作的效率.在nio包中主要包括以下几个类或接口: * Buffer:缓冲区,用来临时存放输入或输出数据. * Charset:用来把Un ...