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就不會顯示文件列表了。