如何防止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就不会显示文件列表了。

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