Multisite on Windows with wildcard subdomains

I want to create a local network on a Windows machine using subdomains. I do not want to edit the hosts file for each new subdomain. But Windows does not support wildcard subdomains, and the Codex doesn’t say anything useful about this topic.

What should I do?

Related posts

Leave a Reply

1 comment

  1. There is a plugin for that: WP XAMPP Multisite Subdomains. Unfortunately, there is no English description available. I’ll try that here.
    The following guide will set up a multi-site under mu.wp with subdomains.

    1. Basic Installation

    Start with a fresh installation of WordPress and XAMPP. Create a network for subdomains. Do not create any sub site yet.

    My XAMPP is installed in E:xampp, WordPress in E:wordpress.latest.final, and my site specific directories in F:sites. There is a directory F:sites_logs for log files.
    Make sure to adjust the paths in the following examples to your set up.

    2. The hosts file

    Open the hosts file. On Win 7 that’s probably on C:WindowsSystem32driversetchosts, and you need administrator rights to edit it.

    Create a separate section like this:

    # BEGIN XAMPP-127.0.0.2
    127.0.0.2           mu.wp
    # END XAMPP-127.0.0.2
    

    Note we use 127.0.0.2, not 127.0.0.1. This is important.

    Save the file, close and forget.

    3. The httpd-vhosts.conf

    Open the Apache vhosts file in /apache/conf/extra/httpd-vhosts.conf.

    Create a new virtual host. If that is your first virtual host you need a generic vhost first.

    generic vhost

    Should be the first virtual host in the file.

    <VirtualHost *:80>
        DocumentRoot "E:/xampp/htdocs"
        ServerName localhost
        <Directory "E:/xampp/htdocs">
            Options Indexes FollowSymLinks
            Options +Includes
            AllowOverride FileInfo
            AllowOverride All
            Order allow,deny
            Allow from all
            DirectoryIndex index.php index.shtml index.html index.htm
        </Directory>
        ErrorLog  "F:sites_logsdefault.error.log"
        CustomLog "F:sites_logsdefault.access.log" combined
    </VirtualHost>
    

    our multi-site vhost

    <VirtualHost 127.0.0.2:80>
        ServerName      mu.wp
        DocumentRoot    "E:wordpress.latest.final"
        <Directory "E:wordpress.latest.final">
            Options Indexes FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
        ErrorLog        "F:sites_logsmu.wp.error.log"
        CustomLog       "F:sites_logsmu.wp.access.log" combined
    </VirtualHost>
    

    Make sure all the paths are correct! Restart Apache.

    4. Install the plugin

    Install the plugin WP XAMPP Multisite Subdomains as a MU-plugin. Usually in wp-content/mu-plugins.

    Done.

    You can create new subdomains now in http://mu.wp/wp-admin/network/site-new.php, the plugin will update the hosts file automatically, and your new sites are available immediately.