127.0.0.1 is the localhost. This is how the computer refers itself. Its a kind of saying “ME”.
The second part is the host that will you will enter in the browser. This can be anything of your choice ranging from site1.local to simply site1.
Save and close the file and you are done adding a host. Now as there is a host setup with a domain we need to inform our Web Server about the same.
Again in Notepad open the file C:\xampp\apache\conf\extra\httpd-vhosts.conf
This is the file which tell the Web Server about the Virtual Hosts residing your computer.
I suppose you have a directory placed under C:\xampp\htdocs\site1 then you can go ahead and add the following line to end of the file.
Whenever you need to add more Virtual Hosts just copy the code from here and paste. You need to change the directory portion though.
Now save the Apache configuration file and close. You need to restart the Apache from XAMPP control to reflect your changes.
Now that we are all setup lets hit the URL in your browser and check if everything is working. Just type http://site1.local and you will have your website running under this URL.
However if you don’t see your website there cross check the directory names and host names.
So, this is how you can setup a Virtual Host in your Windows machine using XAMPP. Will also show you how you can do the same in Ubuntu. Feel free to put your questions/doubts/feedback in the comment section.