Apache Options Indexes FollowSymLinks具体解释



禁止显示Apache文件夹列表-Indexes FollowSymLinks
怎样改动文件夹的配置以禁止显示 Apache 文件夹列表。
缺省情况下假设你在浏览器输入地址:

http://localhost:8080/
假设你的文件根文件夹里有 index.html,浏览器就会显示 index.html的内容,假设没有 index.html,浏览器就会显示文件根文件夹的文件夹列表,文件夹列表包含文件根文件夹下的文件和子文件夹。

相同你输入一个虚拟文件夹的地址:

http://localhost:8080/b/
假设该虚拟文件夹下没有 index.html,浏览器也会显示该虚拟文件夹的文件夹结构,列出该虚拟文件夹下的文件和子文件夹。

怎样禁止 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

   找到例如以下内容:
          ?BR>          <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>
     这种话就禁止在testproject下进行文件夹浏览。

备注: 切记莫把“Allow from all”改成 “Deny from all”。否则,整个站点都不能被打开。
   <Finished>

 另一种方法:

能够在根文件夹的 .htaccess 文件里输入

<Files *>
Options -Indexes
</Files>
就能够阻止Apache 将文件夹结构列表出来。

原文地址:https://www.cnblogs.com/mengfanrong/p/5323704.html