如何防止apache將服務器中的文件列表顯示出來

        1、環境:

                Apache_2.2.6

        2設置

當無法訪問到默認主頁的時候,Tomcat總會自動顯示文件的列表,解決的辦法如下:

        %apache%/conf/httpd.conf中,找到

<Directory "C:/Program Files/Apache Software Foundation/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>

將裏面的Indexes去掉,然後重apache即可解決自動顯示文件列表問題。

雖然這樣子配置,將不會顯示文件列表,但是我們項目的文件夾中還是沒有指定Apache的默認主頁

%apache%/conf/httpd.conf中,找到

<IfModule dir_module>

    DirectoryIndex index.html

</IfModule>

index.html後面添加”index.php”文件來完成添加Apache默認主頁的設置

 

    注意,如果是在集羣環境中,比如JBOSS+APACHE+JK,那麼還需要在集羣中的所有JBOOS中設置禁止文件列表,在%jboss%//server/all/deploy/jbossweb-tomcat55.sar/conf中,

    <init-param> 

              <param-name>listings</param-name> 

              <param-value>true</param-value> 

     </init-param> 

  true改爲false就不會顯示文件列表了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章