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?
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
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
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.
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.1. This is important.
Save the file, close and forget.
Open the Apache vhosts file in
Create a new virtual host. If that is your first virtual host you need a generic vhost first.
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
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.