用Apache仿照FTP的列表方式的虚拟主机配置写法

<Virtualhost *:80>

DocumentRoot “/home/123456”

ServerName ftp.aaa.com

AddDefaultCharset UTF-8

<directory home=””/home/123456″”>

Options Indexes

IndexOptions NameWidth=* //这个是让表格字段名自动适应宽度

IndexOptions FancyIndexing //采用类似Windows的排列方式

IndexOptions FoldersFirst //文件夹排在文件前面

IndexOptions HTMLTable //采用HTML的表格方式

AddIcon (IMG,/icons/pdf.gif) .pdf

AddIcon (IMG,/icons/doc.gif) .doc

AddIcon (IMG,/icons/xls.gif) .xls

AddIcon (IMG,/icons/ppt.gif) .ppt

AddIcon (IMG,/icons/rar.gif) .rar .zip .tgz .tar.gz .rpm .iso

AddIcon (IMG,/icons/msi.gif) .msi .exe

AddIcon (IMG,/icons/txt.gif) .txt

AddIcon (IMG,/icons/dll.gif) .dll .sys

AddIcon (IMG,/icons/xml.gif) .xml

AddIcon (IMG,/icons/html.gif) .htm .html

AddIcon (IMG,/icons/media.gif) .wmv .rm .rmvb .asf .mov

AddIcon (IMG,/icons/img.gif) .jpg .gif .png .bmp

IndexStyleSheet “ftp.css” //指定CSS文件,对样式进行具体规定

AllowOverride None

Order allow,deny

Allow from all

</directory>

</Virtualhost>

Apache虚拟主机配置写法

NameVirtualHost 60.191.43.53:80

<VirtualHost www.ryuhi.com>
ServerAdmin webmaster@ryuhi.com
DocumentRoot E:/vhosts/ryuhi/new_web
ServerName www.ryuhi.com
</VirtualHost>
<Directory
“E:/vhosts/ryuhi/new_web”>
    Options
FollowSymLinks Includes ExecCGI
   
AllowOverride All
    Order
allow,deny
    Allow from
all
</Directory>

<VirtualHost www.zjgps.net>
ServerAdmin webmaster@zjgps.net
DocumentRoot E:/vhosts/hzdjt
ServerName www.zjgps.net
</VirtualHost>
<Directory “E:/vhosts/hzdjt”>
    Options
FollowSymLinks Includes ExecCGI
   
AllowOverride All
    Order
allow,deny
    Allow from
all
</Directory>

在httpd.conf里指定的DocumentRoot和ServerName到这里还要重新写一遍,一般写在最前面,这样的话,Apache会将这个配置作为该IP的服务器的默认访问网站。