Creating Virtual Hosts on XAMPP: A Detailed Walkthrough
This article aims to provide a comprehensive guide to creating virtual hosts on XAMPP. Despite the prevalence of this question, some users may still encounter difficulties.
Steps involved
1. Configure hosts file:
Navigate to: "C:WINDOWSsystem32driversetc" and open the "hosts" file.
Add the following lines:
127.0.0.1 localhost 127.0.0.1 test.com 127.0.0.1 example.com
2. Configure httpd-vhosts.conf:
Navigate to: "xamppapacheconfextrahttpd-vhosts.conf" and add the following:
<VirtualHost *:80> DocumentRoot C:/xampp/htdocs/test/ ServerName www.test.com </VirtualHost> <VirtualHost *:80> DocumentRoot C:/xampp/htdocs/example/ ServerName www.example.com </VirtualHost>
3. Enable Virtual Hosts in httpd.conf:
Navigate to: "C:xamppapacheconfhttpd.conf." Locate the "Supplemental configuration" section and uncomment the following line:
#Virtual hosts Include conf/extra/httpd-vhosts.conf
4. Restart XAMPP
Restart XAMPP Control Panel to apply the changes.
5. Test Virtual Hosts
In a web browser, navigate to:
www.example.com or www.test.com
Note:
If you encounter errors while restarting Apache, check the error logs in "C:xamppapachelogs" and verify that the syntax of your virtual host configuration files is correct.
The above is the detailed content of How Do I Set Up Virtual Hosts on XAMPP?. For more information, please follow other related articles on the PHP Chinese website!