How to setup multiple virtual hosts on XAMPP?

Creating multiple virtual hosts in Windows 10 when using XAMPP is very easy. Let’s get it done in just two steps.
Creating multiple virtual hosts in Windows 10 when using XAMPP
XAMPP Control Panel

Below are the two steps for creating a virtual host in Windows 10 with XAMPP.

Step 1: Open the file httpd-vhosts.conf in a code editor (could be open in notepad as well). 

File location: DriveName:\xampp\apache\conf\extra.

XAMPP Virtual Host File Directory-Curative Artist
XAMPP Virtual Host File Directory

Now copy and paste the below code at bottom of the config file-

     <VirtualHost testvirtual.local>
                 ServerAdmin [email protected]
                 DocumentRoot "DriveName:\xampp\htdocs\testvirtual.local"
                  DirectoryIndex index.php
                  <Directory "DriveName:\xampp\htdocs\testvirtual.local">
                         AllowOverride All
                         Allow from All

Or you can use the below VirtualHost container as well:

<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\testvirtual.local"
<Directory "C:\xampp\htdocs\testvirtual.local">
Require all granted

Save the file and close it if you want else you can close it later.

Step 2: Open the windows virtual host file named as hosts.

The file can be found at location C:\Windows\System32\drivers\etc\
Also, you can use win+r/R to open the file directly.

Windows Host File Command - Curative Artist
Windows Host File Command

There you will see “       localhost” is added already. Leave it as it is.
In next line write  ”       testvirtual.local”


Save the file and restart XAMPP’s Apache server. You’ll see your virtual host running.

Deepak Tiwari
I'm a Software Engineer working with a CMMI Level 3 Company. I started my career as a back-end developer with PHP and now working on various PHP Frameworks', eCommerce platforms , CMS platforms and front-end as well.