How to create multiple virtual hosts in windows with XAMPP?

How to create multiple virtual hosts in windows using 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

Here are the two steps for creating multiple virtual hosts 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.

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”

                 ServerName testvirtual.com

                  DirectoryIndex index.php

                  <Directory “DriveName:\xampp\htdocs\testvirtual.local”>

                         AllowOverride All

                         Allow from All

                  </Directory>

     </VirtualHost>

Save the file and close it if you want else you can close 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.

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

 

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