Named Virtual Host Setup for Local Development


ServerName 127.0.0.1:80

NameVirtualHost *
<virtualhost>
   ServerName 	local
   DocumentRoot "/Sites/htdocs"
</virtualhost>

<virtualhost>
   ServerName 	mysite.local
   DocumentRoot "/Sites/htdocs/mysite"
</virtualhost>

<virtualhost>
   ServerName 	archive.local
   DocumentRoot "/Sites/htdocs/archive"
</virtualhost>

<virtualhost>
   ServerName 	shc.local
   DocumentRoot "/Sites/htdocs/shc"
</virtualhost>

<virtualhost>
   ServerName 	dev.local
   DocumentRoot "/Sites/htdocs/dev"
</virtualhost>

<virtualhost>
   ServerName 	n9.local
   DocumentRoot "/Sites/htdocs/n9"
</virtualhost>

DocumentRoot "/Sites/htdocs"

<Directory "/Sites/htdocs">
   ...
   ...
</Directory>

Apache Configuration (httpd.conf)

127.0.0.1	localhost local
127.0.0.1	mysite.local
127.0.0.1	archive.local
127.0.0.1	shc.local
127.0.0.1	dev.local
127.0.0.1	n9.local
Hosts file. On Unix system, the hosts file is located in /etc/hosts. On Windows system like Windows XP, the hosts file is located in c:\windows\system32\drivers\etc\hosts.
Unix System hosts (/etc/hosts) file; Windows System hosts (c:\windows\system32\drivers\etc\hosts) file.

Typing http://mysite.local/ in your browser will bring up the site you want.