Configure Multiple Domains in apache for local development
12 years ago, May 10, 2012
Reading time: 1 mins
To configure multiple domains or subdomains in WAMP or XAMP's apache server for Local Development using httpd.conf, httpd-vhosts.conf (Virtualhost config) and host file of windows.
First of all open the file: path\to\wamp\bin\apache\Apachex.x.x\conf\extra\httpd-vhosts.conf
[note: x.x.x is the version of apache]
Look for NameVirtualHost *:80 and replace it with: NameVirtualHost *
Next open the file: \wamp\bin\apache\Apachex.x.x\conf\httpd . conf
Look for #Include conf/extra/httpd-vhosts.conf
Delete the # (Uncomment)
Open the file: C:\Windows\System32\drivers\etc\hosts you will need the administrator account to edit this file. On windows 7 Run Notepad as admin and open the file.
For Each domain you will add the following:
127.0.0.1 www.development-domain-here.com
127.0.0.1 www.another-development-domain-here.com
Now in the file \wamp\bin\apache\Apachex.x.x\conf\extra\httpd-vhosts.conf
For Each domain add the following:
<VirtualHost *:80>
ServerName www.development-domain-here.com
DocumentRoot "C:/wamp/www/dev-site/"
</VirtualHost>
<VirtualHost *:80>
ServerName www.another-development-domain-here.com
DocumentRoot "C:/wamp/www/another-dev-site/"
</VirtualHost>
Remove the dummy virtual hosts and add:
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/wamp/www/
</VirtualHost>
Restart the apache service.