Setting up Virtual Hosts on WampServer

If you’re a web developer you know how fantastic WampServer is in allowing you to have Apache, MySQL and PHP server locally under Windows. This allows you to test all your websites locally before you upload them into the “real” server.

Now, the problem is that by default if you have two sites (site1 and site2) locally, it’s always a pain having to browse them by using “” as a URL.

The best way is always to make the URL shorter and for this WampServer allows you to create Virtual Hosts. The general idea of Virtual Hosts is
that you can use something like “http://site1” or “http://site2” instead of having to use the complete URL.

Here’s how you do it:

1. Edit the “hosts” file on your windows system (usually located at c:\WINDOWS\system32\drivers\etc\)

2. Add the following to the end of the hosts file: site1 site2

This tells your computer that any url with a value of ‘site1’ or ‘site2’ should be routed to or more commonly refered to as

3. Save your changes.

4. Now go to “C:\wamp\bin\apache\Apache2.2.17\conf” and edit file “httpd.conf”

5. Search for “httpd-vhosts.conf”

6. Remove the “#” from the beginning of the line “Include conf/extra/httpd-vhosts.conf”

7. Now go to “C:\wamp\bin\apache\Apache2.2.17\conf\extra” and edit file “httpd-vhosts.conf”

8. Add the following lines to the end of this file:

<VirtualHost *:80>
DocumentRoot “C:/wamp/www/site1/”
ServerName site1
ErrorLog “C:/wamp/www/logs/site1.log”
CustomLog “C:/wamp/www/logs/common.log” common
<VirtualHost *:80>
DocumentRoot “C:/wamp/www/site2/”
ServerName site2
ErrorLog “C:/wamp/www/logs/site2.log”
CustomLog “C:/wamp/www/logs/common.log” common

9. Click on the WampServer icon

10. Select “Restart All Services”

And that’s it! From now on you only have to use “http://site1” and “http://site2” as URLs for your 2 local websites.


– These instructions may not work for older versions of WampServer.
– On Windows 7 you will need to edit the “hosts” file running Notepad as Administrator.


  1. Great work man 🙂 well done windows 7 everything ok. Exept that in the vhost texts the quotes are not the appropriate ones and the apache can’t start, but when they are replaced with the “normal” everithing works great.

  2. I switched to wampserver as I was having trouble running apache on windows 7 – it would just start and then stop.

    Your instructions worked perfectly, thank you!

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.