How to Create a Subdomain on WAMP

Virtuals Hosts are handy in making your own domain or subdomains for testing and learning. This tutorial will take you through steps to create subdomain/V-Host on Windows using WAMP.

How to Create a Sub-domain on WAMP

Add an entry in hosts file

Open the hosts file and add an entry for your subdomain the file can be found in the following location on windows7:


This file has no extension just "hosts" file. So you have to open it using notepad and it also requires Administrator persmissions so open it using "Run as Administrator". Add the following lines at the end of file:

Leave the first line as it is where it says "localhost" and the second line is for your main domain and third line is for your subdomain. You can set the and to anything you want I am using it for this tutorial. What actually this file does? is self refrenced loop back ip. Whenever this ip is accessed it will reference the computer it is accessed from. That means the operating system will search for the given hostname on the same computer for server instead of looking it up in DNS.

Open the VirtualHosts file

Now that you have done pointing your domain back to your computer open the "httpd-vhosts" file on the following location for WAMP:


I have WAMP installed in c:\

Add an entry for VirtualHost (Sub-domain)

After opening the file add the following lines for your main domain and sub-domain save the file and exit. Back up the file before you change it.
<VirtualHost *:80>
    DocumentRoot "c:/wamp/www"
<VirtualHost *:80>
    DocumentRoot "c:/wamp/www/roundcube"
DocumentRoot points the directory where files for given domain are stored in my case I have a directory "subdomain" inside of root direcoty "www".

Enable VirtualHosts

Now that you have followed all the instructions properly its time to enable your VirtualHosts in httpd.conf file. The file can be found on the following location:



To open httpd.conf simply left click your WAMP Tray icon, move your cursor over apache, and choose the file httpd.conf in submenu.

After opening httpd.conf search for the following lines and remove the "#" from the beginning of lines then save and exit.

#LoadModule vhost_alias_module modules/
#Include conf/extra/httpd-vhosts.conf

All done now you have to restart WAMP server open your browser and enter and then It should work you can add as many subdomains as you want following these instructions.