How to configure Virtual Hosts on your localhost for windows

Sometimes we need to create virtual hosts in xampp to handle multiple projects because that's easier than accesing the direct path with the localhost URL. Creating a virtual host in xampp is pretty easy, however you may need orientation to configure it correctly for a Laravel project and today we are going to share with you how to do it easily.



Step 1:
Go to the following location:
C:\Bitnami\apache2\conf\httpd.conf

Then search for:
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf

Then comment out:
Include conf/extra/httpd-vhosts.conf
This enables virtual hosts on Apache.

Step 2:
After that go to this C:\Bitnami\apache2\conf\extra\httpd-vhosts.conf location (depending on your setup) &add our projects to the httpd-vhosts.conf file. For adding project add the following lines to the bottom of httpd-vhosts.conf file.

<VirtualHost *:80>
   DocumentRoot "Your project full path from your computer"
   ServerName immigration.local
     <Directory "Your project full path from your computer" >
       Require all granted
     </Directory>
</VirtualHost>


Step 3:
For editing hosts file, Go to C:\Windows\System32\drivers\etc & open the hosts file (If you want to save the changes of hosts file, you need to open it as admin. So right click on the file and click “run as admin”). After that add the following to its end;
127.0.0.1 myproject.local


When you have done all the steps, restart the server for the configuration to be set.