Multiple Virtual Hosts with Windows 7/8/10 and XAMPP

The goal is to make different web projects accessable with various local addresses:

http://webdesign.localhost
http://webentwicklung.localhost

Edit the Windows hosts file

  • 1. Start -> Accessories -> Right click on editor
  • 2. Open as administrator
  • 3. open C:WindowsSystem32driversetchosts
  • 4. Add the following lines to the hosts file:
127.0.0.1 localhost
127.0.0.1 webdesign.localhost
127.0.0.1 webentwicklung.localhost

Configure XAMPP/Apache for your virtual hosts

  • 5. Open the XAMPP configuration-folder
INSTALLATIONS_PFAD/xampp/apache/conf/extra
  • 6. Add the following line to the httpd-vhosts.conf file
NameVirtualHost 127.0.0.1:80
<VirtualHost *>
  # Pfad muss angepasst werden
  DocumentRoot INSTALLATIONS_PFAD/xampp/htdocs
  ServerName localhost
</VirtualHost>
<VirtualHost *>
  # Pfad verweist auf Projekt-Ordner
  DocumentRoot "INSTALLATIONS_PFAD/xampp/htdocs/webdesign"
  ServerName webdesign.localhost
  DirectoryIndex index.php
  <Directory "INSTALLATIONS_PFAD/xampp/htdocs/webdesign">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>
<VirtualHost *>
  # Pfad verweist auf Projekt-Ordner
  DocumentRoot "INSTALLATIONS_PFAD/xampp/htdocs/webentwicklung" 
  ServerName webentwicklung.localhost
  DirectoryIndex index.php
  <Directory "INSTALLATIONS_PFAD/xampp/htdocs/webentwicklung">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>
  • 7. Restart Apache

Tested with:

  • Windows 7/8/10
  • Apache Friends XAMPP (Basis package) version 3.2.2