How Set up Virtual Hosts for XAMPP running on Windows


By default on local Windows development environment (XAMPP), users have to put all web stuff in htdocs directory to work with many projects and experiments. For several projects (such as CMS or frameworks) it’s very useful to have separated virtual host in order to have own document root for each application.

Here are quick and easy steps to create Virtual Hosts for XAMPP.

  1. Navigate to X:\\apache\conf\extra\, For example if XAMPP is installed in directory C:/xampp then navigate to C:/xampp/apache/conf/extra
  2. Open the file named httpd-vhosts.conf with a text editor.
  3. Uncomment the following line by removing #
  4. At the very bottom of the file paste the following code:

    In this snippet testproject.dev virtual host is created and accessible by entering http://testproject.dev in browser’s address bar.
    In order to create your virtual host replace D:/projects/testproject with your project path. and testproject.dev with your virtual host name.

    virtual host name

  5. Edit your Windows hosts file, located at C:/Windows/System32/drivers/etc/ directory. Open it with notepad. Open this hosts and file could look like this:

    and add the following just after that line:

    window host file

  6. Final Step, Restart Apache in XAMPP and test everything.

Leave a Reply

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