image credit goes to https://www.ibm.com/
The term Virtual Host refers to the practice of running more than one web site (such as Demo.Website1.com and Demo.Website2.com) on a single machine. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.
With name-based virtual hosting, the server relies on the client to report the hostname as part of the HTTP headers. Using this technique, many different hosts can share the same IP address.
Name-based virtual hosting is usually simpler, since you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames. Therefore you should use name-based virtual hosting unless you are using equipment that explicitly demands IP-based hosting. Historical reasons for IP-based virtual hosting based on client support are no longer applicable to a general-purpose web server.
Assuming Demo-app as our application here.
To create Name-based virtual host we need to make changes in below 3 files only:
- C:xampp\apache\conf\httpd.conf
- C:\xampp\apache\conf\extra\httpd.vhosts.conf
- C:\windows\System32\drivers\etc\hosts
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\Demo-app\public"
ServerName demo-app
ServerAlias www.demo-app
<Directory "C:\xampp\htdocs\Demo-app\public">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
demo-app
127.0.0.1 demo-app
::1 demo-app
Now Open "http://demo-app" on your favorite browserand Check your newly created Virtual host for Demo-app
That’s it! I hope you have a clear idea of setting up Virtual Hosts for your website with XAMPP running on Windows 10. If you have any queries or suggestions, feel free to ask me via the comment section below.
Reference for deep understanding on Apache Virtual Hosts
Thanks..
MotoShare.in is your go-to platform for adventure and exploration. Rent premium bikes for epic journeys or simple scooters for your daily errands—all with the MotoShare.in advantage of affordability and ease.