How to Create A Virtual Host in XAMPP

Have you ever got tired of having to move all your files to htdocs when you have to test your product? By using a virtual host in XAMPP you can set root folder to a folder other than the default htdocs folder.

  • First go to apache/conf/extra folder in your XAMPP installation folder.

  • Open¬†httpd-vhosts.conf file using your favorite text editor. (Be sure to make a backup of the file in case something went wrong)

Note – I’m using NotePad ++ for this tutorial

  • Add the following code to the file, edit it as required and save the file.
<VirtualHost ksoftlabs.localhost:80>
DocumentRoot "G:/KSOFTLABS/Site"
ServerName ksoftlabs.localhost
<Directory "G:/KSOFTLABS/Site">
  Options All
  AllowOverride All
  Require all granted
  • Go to Windows\System32\drivers\etc folder and open hosts file using a text editor. (Again, backup the original file before editing)

  • Add <Space><Virtual Host Name> to the bottom of the file and save it. You may have to give administrative privileges to save.

  • Restart your apache server from XAMPP Control Panel
  • Type your Server Name in URL to access the root folder.
  • Congratulations! You have successfully created a Virtual Host in XAMPP.



Proud UCSCian | Proud Devan | Computer Geek | Superman | Love Chess & Programming

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.