yes, adding virtual host configuring multiple sites on xampp host is possible. if you have dedicated host to hosting your website and you are using xampp then is it very simple to point multiple sites to same host.
Below are simple steps to do so:
1> considering you have 3 different website and want to point all 3 websites/domain names to same host then first go to your domain name provider and update “A” record to point all domain names to public ip address of the xampp host. in case you dont know how to update dns record then you can simply contact hosting provider to point all domain names to same host.
note – this step can be ignored in case you are testing the scenario with localhost and not with public domain names.
2> go to Xampp installation folder ->open c:/xampp/apache/conf/httpd.conf file, uncomment below line ( remove the # sign from start of line) :
note – just remove the # sign from start of line to uncomment the same.
That will include your vhosts file where we can set up the different sites point to different folders.
3> Go to Xampp installation folder and open c:/xampp/apache/conf/extra/httpd-vhosts.conf file, update the file as below to point multiple sites to multiple directory. you can copy below code as it is but make sure to replace site.com, site1.com, site2.com with your correct website name.
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/site.com" ServerName site.com #ServerAlias </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/site1.com" ServerName site1.com ServerAlias www.site1.com </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/site2.com" ServerName site2.com ServerAlias www.site2.com </VirtualHost>
note- you can add more sites by coping virtualhost block and changing sitename.
finally -> restart apache