# VirtualHost를 사용하여 ServerName마다 설정
<VirtualHost IP주소:포트번호>
ServerName www.dev1.com
...
</VirtualHost>
<VirtualHost IP주소:포트번호>
ServerName www.dev2.com
...
</VirtualHost>
요청(request)에 포함된 Hosts 헤더를 참조하여 "ServerName"와 일치하는 블록을 찾는다.
일치하는 블록이 발견되면 그 블록의 설정이 적용된다.
좀 더 구체적으로 설명을 하자면 "www.dev1.com"과 "www.dev2.com" 두 호스트를 1개 이상의 IP 주소에 할당하고, 각각에 대한 액세스에 대해 다른 동작을 하게 하려면 다음과 같이 설정한다.
<VirtualHost *:80>
ServerName www.dev1.com
ServerAdmin dev@dev.com
DocumentRoot "${SRVROOT}/htdocs-dev1"
CustomLog logs/dev1.accesslog common
ErrorLog logs/dev1.error.log
</VirtualHost>
<VirtualHost *:80>
ServerName www.dev2.com
ServerAdmin dev2@dev2.com
DocumentRoot "${SRVROOT}/htdocs-dev2"
CustomLog logs/dev2.access.log common
ErrorLog logs/dev2.error.log
</VirtualHost>
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 www.dev1.com
127.0.0.1 www.dev2.com