1. 启用httpd-vhosts.conf
在httpd.confg文件中找到
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf(这里将前面的#去掉即可启用虚拟主机)
! 如果是使用套件AppServ之类的还需要启用mod_vhost_alias.so模块(#LoadModule vhost_alias_module modules/mod_vhost_alias.so)
2. 配置httpd-vhosts.conf
<VirtualHost *:80>
#配置网站站点根目录(例如:d:/mywebsite)
DocumentRoot "d:/mywebsite"
#配置网站域名
ServerName www.website.com
#下面配置网站根目录的相关属性('/' <=> 'd:/mywebsite' )
<Directory />
#配置在没有指定网站首页面时,是否显示目录结构列表
Options index FollowSymLinks
#配置修改权限(None 表示不允许)
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
#配置网站的首页面
DiectoryIndex index.html index.htm index.php
#配置网站404错误页面
errorDocument 404 /404.html
</Directory>
</VirtualHost>
Options index FollowSymLinks: 如果这里有index则指明可以显示目录结构列表,如果不想显示目录结构料,有如下几种方式:
① 将index直接去掉即可
②httpd.confg文件中找到如下内容
<Directory "C:/AppServ/www"> #这里C:/AppServ/www是apache服务器默认的根目录 # 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 MultiViews ExecCGI # # 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 All # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory>
在Options Indexes FollowSymLinks MultiViews ExecCGI中的index加‘-’即可,即Options -Indexes FollowSymLinks MultiViews ExecCGI,此时整个apache服务器都禁止目录浏览
③在虚拟主机中的 Options index FollowSymLinks中的index前加‘-’即可,即 Options -index FollowSymLinks