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去掉目录浏览的更多相关文章

  1. 关闭或者开启apache的目录浏览

    为了安全或者方便需要关闭或者开启apache的目录浏览   关闭目录浏览    修改http.conf 文件    Options Indexes FollowSymLinks     改为      ...

  2. Apache索引目录浏览的学习笔记

    在浏览一些镜像文件站的时候,会发现网站目录是可以浏览文件(夹)列表的.举两个例子:网易开源镜像:Ubuntu.只要 Web 服务器是基于 Apache 的网站都可以开启或禁止索引(目录浏览),那么如何 ...

  3. Nginx 和 Apache 开启目录浏览功能

    1.Nginx 在相应项目的 Server 段中的 location 段中,添加 autoindex on.例如: server { listen ; server_name www.dee.prac ...

  4. nginx和apache配置目录浏览功能

    今天工作需要,要给客户提供一个patch的下载地址,于是想用nginx的目录浏览功能来做,需要让客户看到指定一个目录下的文件列表,然后让他自己来选择该下载那个文件: 我们都知道在apache下可以配置 ...

  5. Ubuntu apache 禁止目录浏览

    $ sudo vim /etc/apache2/sites-enabled/000-default 将Options后面Indexes前面加上"-"表示禁止目录浏览: <Di ...

  6. 关闭Apache的目录浏览功能

    一.默认情况 默认情况下,Apache的配置文件C:\web\apache2.4\conf/httpd.conf中有如下参数: 引用 <Directory "/var/www/html ...

  7. mac上Apache修改目录浏览权限

    sudo vim /etc/apache2/httpd.conf <Directory "/Library/WebServer/Documents"> # # Poss ...

  8. apache的目录浏览功能 列出的文件名不完整,能否修改设置

    在httpd.conf 和 httpd-vhosts.conf中的  <Directory ????> </Directory>如下设置,重启apache即可: <Dir ...

  9. Apache开启目录浏览功能的正确姿势

    部分代码是抄的网友的,哪儿抄的忘了,我是自己修改了点,并非我本人原创,觉得侵权联系我,立马删 在宝塔面板中,打开网站的设置,在配置文件那里添加如下内容 Directory "文件绝对路径&q ...

随机推荐

  1. pytorch版本问题:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'

    用pytorch加载训练好的模型的时候遇到了如下的问题: AttributeError: 'module' object has no attribute '_rebuild_tensor_v2' 到 ...

  2. iOS如何隐藏状态栏,包括网络标志、时间标志、电池标志等

    我们在开发App的时候,在遇到有状态栏时,NavigationBar上面的按钮,是极难点击的,所以这个时候,最好我们能够人为的隐藏掉状态栏. 如果一直需要隐藏的话,直接在info.plist里面,添加 ...

  3. 使用 Entity Framework 返回 JsonResult 时循环引用的避免【EF 转 JSON】

    var ui = (from u in _db.USER_INFO select u).FirstOrDefault(); // 单个实体的用法 ZRQCommon.EntitiesTools e = ...

  4. [codeforces] 526D [51nod] 1554 欧姆诺姆和项链

    原题 KMP 方法一: 听说是ex-kmp--来自学姐 ex-kmp是处理两个串s和t之间,t的每一个后缀在s中的最长前缀的长度的一个算法. 它很像manacher(至少我和学姐这么认为),记录了一个 ...

  5. POJ 2406 Power Strings 暴力

    emmmm 显然的是a串长度是s串长度的因数 我们可以暴力枚举因数然后暴力check #include<cstdio> #include<algorithm> #include ...

  6. Sublime Text 2 HTML代码缩进 美化HTML代码

    关于代码格式的美化,之前在win下一直用“alignment”这个插件,它能实现一键对齐和缩进.最近使用mac版的sublime text 2,不知道是什么原因,这个插件疑似失效…… 这对有洁癖的完美 ...

  7. 重复登录Windows远程桌面-Autoit脚本

    非常抱歉,我先临时把脚本放上来,具体的说明有时间再更新: 都是做成快捷方式,用鼠标点击的操作 #include <AutoItConstants.au3> ; Open mstsc pro ...

  8. P2625 豪华游轮 (背包$dp$,数学)

    题目链接 Solution 贼有意思的一个题目. 可以发现阻止我们走的更远的就是那些需要反向走的路程. 然后发现当角度越接近 \(180^\circ\) ,对我们最终的答案则更优. 所以先是一个背包把 ...

  9. Android横竖屏总结(转)

    Android横竖屏总结(转) 横竖屏切换后Activity会重新执行onCreat函数,但是在Android工程的Mainfest.xml中加入android:screenOrientation=& ...

  10. codechef AUG17 T2 Chef and Mover

    Chef and Mover Problem Code: CHEFMOVR Chef's dog Snuffles has so many things to play with! This time ...