本文涵蓋了apache伺服器中常用的vhost配置方法,由于時間關系不在文中進行講解,僅供參考。
#
# virtual hosts
#
# if you want to maintain multiple domains/hostnames on your
# machine you can setup virtualhost containers for them. most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# ip addresses. this is indicated by the asterisks in the directives below.
# please see the documentation at
# for further details before you try to setup virtual hosts.
# you may use the command line option '-s' to verify your virtual host
# configuration.
# use name-based virtual hosting.
namevirtualhost *:80
# virtualhost example:
# almost any apache directive may go into a virtualhost container.
# the first virtualhost section is used for all requests that do not
# match a servername or serveralias in any <virtualhost> block.
<virtualhost *:80>
documentroot "c:/wanmp/apps/web1.vtest.org"
servername web1.vtest.org
# serveralias web1.vtest.org
<directory "c:/wanmp/apps/web1.vtest.org">
options indexes
order allow,deny
indexoptions name charset=utf-8
allow from all
</directory>
errorlog "logs/web1.vtest.org-error.log"
customlog "logs/web1.vtest.org-access.log" common
</virtualhost>
documentroot "c:/wanmp/apps/web2.vtest.org"
servername web2.vtest.org
errorlog "logs/web2.vtest.org-error.log"
customlog "logs/web2.vtest.org-access.log" common
documentroot "c:/wanmp/apps/bbs.vtest.org"
servername bbs.vtest.org
errorlog "logs/bbs.vtest.org-error.log"
customlog "logs/bbs.vtest.org-access.log" common
<directory c:\wanmp\apps\bbs.vtest.org/ >
options followsymlinks
allowoverride all
# order deny,allow
# deny from all
rewriteengine on
rewritebase /
rewritecond %{query_string} ^(.*)$
rewriterule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
rewriterule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
rewriterule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
rewriterule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3d$3&page=$2&%1
rewriterule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
rewriterule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
rewriterule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
rewriterule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
rewriterule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1

2&%1
documentroot "c:/wanmp/apps/sns.vtest.org"
servername sns.vtest.org
errorlog "logs/sns.vtest.org-error.log"
customlog "logs/sns.vtest.org-access.log" common
documentroot "c:/wanmp/apps/www.vtest.org"
errorlog "logs/www.vtest.org-error.log"
customlog "logs/www.vtest.org-access.log" common
documentroot "c:/wanmp/apps/sql.vtest.org"
servername sql.vtest.org
errorlog "logs/sql.vtest.org-error.log"
customlog "logs/sql.vtest.org-access.log" common
documentroot "c:/wanmp/apps/dns.vtest.org"
servername dns.vtest.org
errorlog "logs/dns.vtest.org-error.log"
customlog "logs/dns.vtest.org-access.log" common
documentroot "c:/wanmp/apps/php.vtest.org"
servername php.vtest.org
errorlog "logs/php.vtest.org-error.log"
customlog "logs/php.vtest.org-access.log" common
documentroot "c:/wanmp/apps/tmp.vtest.org"
servername file.vtest.org
errorlog "logs/file.vtest.org-error.log"
customlog "logs/file.vtest.org-access.log" common
<directory "c:/wanmp/apps/tmp.vtest.org">
servername proxy.vtest.org
errorlog "logs/proxy.vtest.org-error.log"
customlog "logs/proxy.vtest.org-access.log" common
servername main.deploy.elp
documentroot "c:/wanmp/apps/main.vtest.org"
# logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\"" combined
logformat "%h %l %u %t \"%r\" %>s %b" vhostcommon
customlog logs/main.deploy.elp-access.log vhostcommon
errorlog "logs/main.deploy.elp-error.log"
</virtualhost>