XAMPP virtual hosts setup is quite easy. There are some reasons to use virtual hosts. Although, your XAMPP works fine if you don’t configure virtual hosts. To use custom domain / virtual hosts, you must designate the IP address or (Port, if available). Lets have a look why do we need to create virtual hosts at local server.
Reasons – Creating virtual hosts
- Test your web projects on local server as same as original domain name.
- To work at 2 or more domains.
- Maintain your web projects with the name.
- Good for absolute path (I personally create for this reason).
Step #1 – Assign Hosts Name
Windows have a file with the name of “hosts” which can be located at “C:\Windows\System32\drivers\etc\”. Let put your local server IP which usually defined already “127.0.0.1″. Start with the local IP and place “space or tab” to define virtual hosts / domain name. See Figure #1.
Step #2 – Setting up virtual hosts in XAMPP
I am writing step by step, I hope it would be great for you.
- Explore your XAMPP Apache folder and find “httpd-vhosts.conf” at mentioned path “C:\xampp\apache\conf\extra”
- Open the file in text editor.
- Paste or write below lines into your Apache hosts file.
6. Restart your XAMPP and open the domain (http://yourdoamin.com).