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 將文件夾結構列表出來。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM