Introduction
Virtual hosts allow you to run multiple websites on a single XAMPP installation. This guide walks you through configuring Apache to support virtual host configurations.
Step 1: Configure httpd.conf
Navigate to the Apache configuration file at xampp/apache/conf/httpd.conf.
Enable Virtual Hosts Module
Search for the keyword httpd-vhosts.conf and ensure the following line is uncommented:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Update Directory Permissions
Find the AllowOverride All directive and modify the directory block:
<Directory "D:/xampp/cgi-bin">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Set Document Root
Locate the DocumentRoot directive and set your desired project root path:
DocumentRoot "D:/www"
Step 2: Configure httpd-vhosts.conf
Open the virtual hosts configuration file at xampp/apache/conf/extra/httpd-vhosts.conf.
Option A: Access by IP Address
<VirtualHost 127.0.0.5:80>
DocumentRoot "D:/www"
ServerName myproject.local
</VirtualHost>
Option B: Access by Domain Name
<VirtualHost *:80>
DocumentRoot "D:/www"
ServerName myproject.local
</VirtualHost>
Step 3: Update Hosts File
Edit the system hosts file located at C:\Windows\System32\drivers\etc\hosts and add the following entry:
127.0.0.1 myproject.local
Important Note
After completing the configuration changes, restart the Apache server in XAMPP control panel before attempting to access your virtual host.