Enabling Multisite for WordPress on Windows and IIS

Introduction

This article will walk you through the process of turning on Multisite for IIS. It is assumed that you have a working installation of WordPress on Windows Server and IIS, and that you have a current backup. If you need a tutorial on installing WordPress on Windows Server 2012 and IIS 7.5+, then check out our prior article: A Comprehensive Guide To Installing WordPress on Windows and IIS.

Pre-requisites

  1. If you have not already done so, download and install the URL-Rewrite module for IIS. As of the time of writing, you are looking for version 2.0 or later.
  2. Decide if you want your sites in your multisite to be referenced using subdomains or subdirectories.
    1. With subdomains, your sites will be referenced as subdomain.mydomain.com
    2. With subdirectories, your sites will be referenced as mydomain.com/subdomain

Install and Configure MultiSite

  1. Open your wp-config.php file and edit it to add the following line:
    1. define(‘WP_ALLOW_MULTISITE’, true);
    2. Note — the line must be added above the line in the file that says “/* That’s all, stop editing! Happy blogging. */”
  2. Deactivate ALL Plugins on your site.
  3. Login to your site and go to Tools->Network Setup
  4. On the screen that appears, select whether you want to use subdomains or subdirectories.
    1. I recommend subdomains, even though it’s a bit more difficult to set up, since you have to deal with DNS settings and wildcard URLS which IIS does not support very well.
    2. If you are shown a notice about your domain name and that name contains a “www” in it, do not continue. Instead, exit and fix the domain name in your wp-config.php file. A “www” in the current domain name will wreak havoc with your subdomain names later.
  5. Click the Install button.
  6. You will be shown two text boxes.
    1. One is for a list of items that need to be placed into your wp-config.php file. Go ahead and do that.
    2. The other is for a list of commands for your web.config file. Copy that into a safe place — it is usually wrong, but you will need it for troubleshooting later. Instead, use the contents shown at the bottom of this article.
  7. Multisite should now be activated — you will have to logout and log back in to see the new “Sites” option in your menu.

Contents of the Web.config File

The following should be placed in your web.config file. The green colored lines should be included, but you will notice that they are between HTML comment brackets. They are for use when SSL is enabled on Multisite, which is the subject of a future article.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>

		<clear />
		<!--
                <rule name="Redirect to https" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
                </rule>
-->
		
                 <rule name="WordPress Rule 1" stopProcessing="true">
                    <match url="^index\.php$" ignoreCase="false" />
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 2" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
                </rule>
                <rule name="WordPress Rule 3" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                    <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
                </rule>
                <rule name="WordPress Rule 4" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 5" stopProcessing="true">
                    <match url="(^[_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </rule>
                <rule name="WordPress Rule 6" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </rule>
                <rule name="WordPress Rule 7" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>

            </rules>
        </rewrite>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="iisstart.htm" />
                <add value="default.aspx" />
            </files>			
        </defaultDocument>
		
    </system.webServer>
</configuration>
Comments 0