Set up multiple virtual hosts on XAMPP for windows

You just have to update the following files:



First of all,  uncomment the following line to enable name based virtual host on your server’s port 80:

NameVirtualHost *:80


Then you can start adding your virtual hosts. The following listing is just a sample, I usually do.I am assuming ,we create a project which should be accessible by entering http://demo-project in your browser’s address bar.

<VirtualHost *>
DocumentRoot “X:/xampp/htdocs”
ServerName localhost

<VirtualHost *>
DocumentRoot “X:/xampp/htdocs/mywebsite/webroot”
ServerName test-project

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot X:/xampp/htdocs/demo-project/public
ServerName demo-project

<Directory “X:/xampp/htdocs/demo-project/public”>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all


Make sure the DocumentRoot exists and matches the Directory and remember the value you set for ServerName.


2. Edit your windows hosts file

Now your apache is ready,but you have to tell your system what to do if you enter http://demo-project in your browser.The most simple way to deal this is to update your hosts file you can find it from here.


(Path wil be different if windows installed else where)


The file is just a simple text file which contains IP-to-hostname mappings. Edit the file with a text editor and append a new line which maps the hostname you specified in apache’s ServerName-directive to You can place it just under the existing one which defines localhost. In the end, your file could look like this:

# some comments        localhost        test-project        demo-project


Restart your Apache Server in order to load the new configuration and enjoy 🙂