How to set up multiple virtual hosts on XAMPP windows

How to set up multiple virtual hosts on XAMPP windows

It requires two main steps:

  1. Add Virtual Host Entries to vhosts Configuration file.
  2. Assign IP to your “Virtual Host”, editing windows hosts file.


Open Config file:


in my case it is located here: C:\Server\xampp56\apache\conf\extra\httpd-vhosts.conf

Remove Comment for below line:

##NameVirtualHost *:80

Add Following Entry:

 <VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/Server/xampp56/htdocs/mistersuraj"
ServerName mistersuraj

<Directory "C:/Server/xampp56/htdocs/mistersuraj">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all

Important Note: You will have to change DocumentRoot , Directory and ServerName

Change DocumentRoot and Directory to absolute path of the directory that contains your website files.
In my case it is:
In Your case it can be:
C:/Server/xampp56/htdocs/your-project OR anything you like but it must exists in your computer.

Both DocumentRoot and Directory must have same path.

Change ServerName to “Anything you like” but please give simple string to make your life easier. lets make it “your-project

In my case it is:
mistersuraj and I can access it like http://mistersuraj/ in my browser

In Your case it can be:
your-project and You can access it like http://your-project/ in your browser

Virtual Host Config is done. Lets move to second step:


Open your Windows hosts config file ( hosts )

it is usually here: C:\Windows\system32\drivers\etc you need administrator privileges to edit the file

Add this entry to hosts file: your-project

So that it will look like this: localhost your-project

Important Note: Ensure you have single ip and string in each line.

We are done!!!

Restart Your XAMPP

Open your newly created url in your browser : http://your-project/ 

You can as many virtual hosts you want but for each host you must have entries in httpd-vhosts.conf and windows hosts file.

Important Note: If you have .htaccess file in your folder ensure you have correct RewriteBase path set. It can work with RewriteBase / only

Share this post

Leave a Reply

Select Your Currency