WordPress Multisite on windows server, web.config

1
96

If you are hosting a wordpress envirement on a windows server there a few things to look out for. One of them is creating a web.config file.

A standart wordpress system comes with a .htaccess file to manage the routing of the subpages. This one you have to replace.

WordPress multisite web.config file

Just create a new file called web.config in your wordpress base-folder and add this xml-code:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <!--<security>
            <authentication>
                <basicAuthentication enabled="false"/>
                <anonymousAuthentication enabled="false"/>
            </authentication>
        </security>-->
        <rewrite>
            <rules>
                <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" />
                        <add input="{URL}" pattern="([a-zA-Z0-9\./_-]+)\.axd" />
                    </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:1}" />
                </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>
    </system.webServer>
</configuration>

Your website should work right away.

If you were looking for the web.config of a normal wordpress installation check out this article.

1 COMMENT

  1. Hey, I had 2 days finding a solution for my Folder-based WordPress. At the end it was the rule #2 about the ms-files.php that allow me to see loaded the JS and CSS. I used the WordPress code example, but didn’t work. Thanks Bro, you made me go to sleep early today, hah!

LEAVE A REPLY

Please enter your comment!
Please enter your name here