There appears to be a bug on the web.config
file generated by WordPress, up to version 4.7.2, where the rewrite rules do not work as needed to access the sites defined in the network.
When using, for instance, sub-dir for the multisites configuration, trying to access mysite.com/subsite/wp-admin/
gives a 404 error.
1 Answer
As per this issue on the WordPress trac, the problem are the rules 4 and 5.
The solution is to change the url parameter and add 1, so, instead of this:
<rule name="WordPress Rule 4" 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 5" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
<action type="Rewrite" url="{R:2}" />
</rule>
You have this:
<rule name="WordPress Rule 4" 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 5" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
<action type="Rewrite" url="{R:3}" />
</rule>
Doing this change allows the multisite feature to work.