Create virtual hosts in Windows XAMPP

Wonder how you can create virtual hosts and access your sites in more fancy way or want to multidomain websites? Well,its pretty easy, follow below steps to achieve it.
  1. To do this you must have installed XAMPP or WAMP, whichever you prefer. I have XAMPP so the steps would be more related to XAMPP. But you can follow these for WAMP as well.
  2. You also must need to have admin rights to your computer.
Now follow below steps,
  1. Open Notepad by right clicking on it and select "Run as Administrator"
  2. Then click "File" -> on open file fron URL "C:\Windows\System32\drivers\etc" named "hosts". (Note: If you cant see any file then select "All Files" in the bottom)
  3. Once you have opened it put "       localhost" in one line and just below your domain name like "" and save it.
  4. Then go to your XAMPP/WAMP directory and find "httpd-vhosts.conf" file. It must be inside Apache directory. In my case its in "C:\xampp\apache\conf\extra" and open it.
  5. Then copy the code insde it which is commented and paste below. The code looks something like,
    ##<VirtualHost *:80> 
        ##DocumentRoot "C:/xampp/htdocs/"
        ##ErrorLog "logs/"
        ##CustomLog "logs/" common
  6. Remove commnets and make changes as per your needs. So in my case those would be like,
    <VirtualHost *:80>
        DocumentRoot "C:/xampp/htdocs/umesh-files"
        ErrorLog "logs/"
        CustomLog "logs/" common
  7. Then go to XAMPP/WAMP control panel and restart the Apache.
  8. Now paste your newly created domain in browser (in my case it is "") address bar and you are good to go.

Hope this has helped you, if you are facing any issies starting Apache then go to XAMPP's root directory and run batch file named "apache_start.bat" and it will show if there are any errors.

If you still have trouble with this please write me in comment section below.




Add new comment