How to configure multiple sites on one XAMPP htdocs and edit your hosts file
Changing the Hosts File
Click start search for notepad. Right click and run as administrator. Click open, in the search bar at the top pastec:\windows\system32\drivers\etc\hosts
Under the comments add 127.0.0.1 nameofyoursite.test
Virtual Hosts
OpenC:\xampp\apache\conf\extra\httpd-vhosts.conf
Uncomment the below line to enable name based virtual hosts on your XAMPP. NameVirtualHosts *:80
At the end of the file add: <VirtualHost *:80>
DocumentRoot "C:\XAMPP\htdocs"
ServerName localhost
</VirtualHost>
//When you load the site if you get directory listings then remove this virtual host.
For each site you want to have then add:<VirtualHost *:80>
DocumentRoot "C:\XAMPP\htdocs\nameofyoursite"
ServerName www.nameofyoursite.test
<Directory "C:\XAMPP\htdocs\nameofyoursite">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Checks
In cmd navigate toC:\xampp\apache\bin
//then run
httpd.exe -t
//Should return
Syntax OK
Test
In your browser go to www.nameofyoursite.test and you should have your website. Repeat for multiple sites.Notes
If you recieve "Your connection is not private" then it may be because you are using .dev, change to .test to get it to work.Categories: Posts