Virtual Hosts in XAMPP on Windows 7 64-bit

Out of the box XAMPP only displays a single website, which is located in the htdocs directory. If needed, multiple websites can be served by implementing virtual hosts, which only requires editing 2 files. If you’ve been working with another type of server and have not been able to figure this out, don’t worry because it’s really easy.

In the <xampp>/apache/conf/extra directory, you will find a file named http-vhosts.conf. Lets say we want to add a domain named example and that it will be located at C:\xampp183\htdocs\example, here’s what we add to the conf file:

	<VirtualHost *:80>
	    ServerName example
	    DocumentRoot "C:\xampp183\htdocs\example"
	<VirtualHost *:443> 
	    DocumentRoot "C:\xampp183\htdocs\example"
	    ServerName example
	    SSLEngine on 
	    SSLCertificateFile conf/ssl.crt/server.crt 
	    SSLCertificateKeyFile conf/ssl.key/server.key 

We also need to tell your computer to route any request for the example domain to localhost (, so we need to edit the hosts file. My hosts file is located at C:\Windows\System32\drivers\etc. At the bottom of the hosts file, we just add the following line:     example

You can’t edit this file correctly unless you run Notepad as an administrator. To do that you simply right click on your Notepad icon and select “Run as Administrator”.

When you add a domain, you need to restart Apache if it was running. Restart, and then you should be able to access your new domain, http://example‘, ‘Virtual Hosts in XAMPP on Windows 7 64-bit

3 thoughts on “Virtual Hosts in XAMPP on Windows 7 64-bit”

  • Hi Brian, I use the exact same method as you’ve described, including running a site over https locally. Everything works fine.
    The problem I’m having is running multiple sites over https locally. If I enter two VirtualHost entries with *:443, the second site just redirects to the first one in the file. I’m currently having to comment these VirtualHost blocks out and restarting apache to be able to edit multiple sites. Have you found a way to run multiple https sites?


    • Hi Chris. I actually always had multiple HTTPS sites without the kind of issues you are experiencing. It shouldn’t really matter if you’re using XAMPP or not, because the Apache config would be similar regardless of how it was installed. I think it would be good for you to ask your question over at or another forum that has dedicated Apache support. There are some real geniuses over at PHP Freaks. You’d for sure get an answer, or at least some help.

  • Hi gents, I having same problem as Chris, Can’t run two https sites at the same time, What to do?

Comments are closed.