Create virtual hosts in Windows XAMPP
- 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.
- You also must need to have admin rights to your computer.
- Open Notepad by right clicking on it and select "Run as Administrator"
- 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)
- Once you have opened it put "127.0.0.1 localhost" in one line and just below your domain name like "127.0.0.1 umesh.localhost.com" and save it.
- 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.
- Then copy the code insde it which is commented and paste below. The code looks something like,
##CustomLog "logs/dummy-host2.example.com-access.log" common
- Remove commnets and make changes as per your needs. So in my case those would be like,
CustomLog "logs/umesh.localhost.com-access.log" common
- Then go to XAMPP/WAMP control panel and restart the Apache.
- Now paste your newly created domain in browser (in my case it is "umesh.localhost.com") 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.