How to: Setup Multiple Virtual Hosts in WAMP Server

wamp5_logoWAMP, or Windows Apache MySQL PHP has been a very server for lots of PHP developers who uses Windows environment. These are mainly the freelancers who mostly uses laptops as their local development machines. Whatever may be the reason, but when you use WAMP, it becomes difficult to manage multiple application installed in same root.

For example while we use WAMP as a development environment, we have different client specific projects residing in different folders in the root and whenever these projects needs to be uploaded in production environment, the absolute paths has to be manually change.

What if we want to have different root folder for each client? Well, this is possible in WAMP using Virtual Hosts. Let us see how to setup the virtual hosts.

First we need to modify two files to create virtual hosts:

  1. hosts file: This file is in the c:\windows\system32\drivers\etc\ folder
  2. httpd.conf file: This is in your Apache install’s ‘conf’ folder – e.g. c:\wamp\Apache2\conf\httpd.conf

The hosts files has entries which maps IP Address to a name. By default the name “localhost” is mapped to IP Address.        localhost

Now what we have to do is to simply add few more entries per client in this file. You may want to use your clients domain name as mapping key (e.g. viralpatel.local)        client1.local

Add as many entries as you want in hosts file. Whenever you enter “client1.local” in your web browser, windows will first look into hosts file and if it gets the corresponding entry, it sends the request to that IP Address.

Now we have to change httpd.conf. Open the httpd.conf file and search for something like:

'DocumentRoot 'c:/wamp/www'' 

Add following code after the ‘DocumentRoot “c:/wamp/www”‘ entry in httpd.conf file.


    ServerName localhost
    DocumentRoot 'C:\wamp\www'

    ServerName myclient.local
    DocumentRoot 'C:\wamp\www\ClientsMyClient'

And now you need to modify the code a bit to match the server name with the one from your ‘hosts’ file and the DocumentRoot with your clients file path.


  • amit 10 November, 2009, 19:35

    Quite helpful

  • Gaurav Gupta 8 January, 2010, 12:23

    thankx, it was helpful

  • thom 23 April, 2010, 16:08

    does not work

  • Chathura 25 April, 2010, 18:09

    Thank you for sharing this great tutorial

  • Nimesha 1 October, 2010, 15:07

    Your blog posts are really helpful.This is for windows operating system. I have written this for Linux.

  • serty 22 May, 2011, 19:39

    Isn’t that cute? But it’s wrong!
    Doesn’t work by me. I used *:80 instead of and everything started to work as it should. Cheers!

  • Dan 29 January, 2012, 1:59

    *:80 is what I usually use instead of

    I’ve posted an article on setting up multiple virtual hosts in WAMP with little effort

  • Neelesh 31 May, 2012, 17:26


  • coz 9 June, 2012, 4:38

    The tutorial is bad practice. This is the right way to do it.
    In httpd.conf uncomment
    LoadModule vhost_alias_module modules/
    That loads up the virtual hosts file
    Then in extra/httpd-vhosts.conf
    add your virtual containers

  • nha 25 October, 2012, 20:01


  • Aset 18 November, 2012, 18:37

    Code worked for me! But correction needed.
    1) Go to “C:\wamp\bin\apache\apache2.2.11\conf” folder and open “httpd.conf” file.
    Uncomment “#Include conf/extra/httpd-vhosts.conf” by removing # sign.
    2) Now open “httpd-vhosts.conf” file and add :

    ServerName localhost
    DocumentRoot ‘C:\wamp\www’

    ServerName myclient.local
    DocumentRoot ‘C:\wamp\www\ClientsMyClient’

    change data according to your folder name.
    Section on adding entry in hosts file is correct.

  • Aset 18 November, 2012, 18:40

    Sorry, I forgot to use tags and code is shown differently, use code from the article, but open another file which I indicated.

  • Sandeep 4 February, 2013, 2:58

    Thanks a lot….
    For me it is highly helpful, because I have setup static servers for static content. So I redirected static servers to a folder inside localhost….

    So, it saved my time…..

    Thanks again

  • shyantan 6 February, 2013, 22:24

    thanks a lot admin , at last i have success fully setup multiple hosting in WAMP server

  • Jon 20 February, 2013, 5:56

    Out of about 5 different tutorials on this subject, this one was the only one that worked, thanks!

  • Taryono 3 May, 2013, 7:57

    mantap bro….

  • Gibson 29 June, 2013, 14:20

    I have all whag you suggested but nothing done it does not work for me

  • Maxim 1 July, 2013, 23:47

    Thanks, you saved my time.

  • TARYO 2 August, 2013, 11:46

    great!,, thanks

  • saran 12 August, 2013, 22:01

    Awesome info. Worked to me without any issues.

  • saran 12 August, 2013, 22:15

    But the problem is that, I have created three virtual host with test php files. The first one is working fine. Other two is taking too much time. Let me know if I need to change something in this files.

  • Joseph Bailey 31 July, 2014, 23:47

    It depends on what wamp you have to do it how he did or have to uncomment

     Include conf/extra/httpd-vhosts.conf 

Leave a Reply

Your email address will not be published. Required fields are marked *


To post source code in comment, use [code language] [/code] tag, for example:

  • [code java] Java source code here [/code]
  • [code html] HTML here [/code]