Skip to content
Home » Create Multiple Virtual Hosts in Windows

Create Multiple Virtual Hosts in Windows

Virtual Host let you run multiple Websites on your computer.
It also lets you store the files for those sites anywhere on your computer and not just in the C:XAMPP/htdocs folder.
The process to create VIrtual Host:
1. Add a new entry to your computer’s hosts file:
  • It tells the computer to NOT go out on the internet when you type a particular URL like http://projectA/  but instead look for that particular domain on your own computer.
  • Add the below line at the end of file hosts which is located at C:windows/system32/drivers/etc
    127.0.0.1      projectA
    127.0.0.1

    • This is how a computer refers to itself, it’s an IP address that points back to the computer, kind of like a computer’s way of saying “ME”.
    • The second part (projectA) is the “domain” of the virtual host.
Edit Apache configuration file to accept Virtual Hosts and define the particular Virtual Hosts:
  • It tells Apache where the files for the site are located on your computer.
  • Add the below codes at the end of file httpd-vhosts.conf located at C:xampp/apache/conf/extra
    NameVirtualHost *
    DocumentRoot "C:xampphtdocs"
    ServerName localhost
    
    DocumentRoot "H:testingprojecttestA"
    ServerName projectA
    
    Order allow,deny
    Allow from all

Restart apache and http://projectA/ will be accessible from a web browser.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

0 Shares
Tweet
Pin
Share
Share
Share