Multiple LocalHost Sites

I’ve got XAMPP installed on a Windows 7 machine. I wanted a way to test multiple sites locally.

Set up the local host file

In your host file, add (replace with the domains you want):

UPDATE: Thanks to the host file edits are optional if you use the style (replace with your actual IP address). This is compatible with Adobe’s Edge Inspect.

Set up XAMPP config files

In \xampp\apache\conf\httpd.conf uncomment the following at about line 140:

LoadModule vhost_alias_module modules/

I’ve used the folder structure of “\xampp\htdocs\\web\content\files.php” (for example) and the following config will find the folder with the exact name in the url.

In \xampp\apache\conf\extra\httpd-vhosts.conf:

NameVirtualHost *:80

<virtualhost *:80>
    DocumentRoot C:/xampp/htdocs/

# New: No hosts file edits if you use this style
# Replace X.X.X.X with your local IP
<virtualhost X.X.X.X:80>
    # Handle Edge Code IPs
    VirtualDocumentRoot D:/xampp/htdocs/websites/%-7+/web/content/
    ServerAlias *
    php_admin_value auto_prepend_file D:/xampp/setdocroot.php

<virtualhost *:80>
    VirtualDocumentRoot C:/xampp/htdocs/%-2+/web/content/
    ServerAlias *.dev
    php_admin_value auto_prepend_file C:/xampp/setdocroot.php


If you are having issues with DOCUMENT_ROOT, create setdocroot.php at “\xampp\” and put the following in it:



ResponseEncoding in IIS7 for static html files in web.config

I couldn’t find any way to set ResponseEncoding in IIS7 for static html files in web.config.

The system.web setting using globalization doesn’t seem to fit anywhere in system.webServer like it seems like it should (someone please let me know if there is a way to do that).

Anyway, I did find a way to sort of shove it in there:

  <system .web>
    <!-- not applied to HTML files -->
    <globalization requestEncoding="utf-8"
       responseEncoding="utf-8" />
  <system .webServer>
      <!-- This does get applied to HTML files -->
      <mimemap fileExtension="html"
         mimeType="text/html; charset=utf-8" />