Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
web.config for IIS hosted multi-site WordPress
<!-- http://lauragentry.com/blog/2010/07/30/how-to-create-a-wordpress-3-0-multisite-network-on-a-windows-server-using-sub-directories/ -->
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<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" />
</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>
</system.webServer>
</configuration>
@HoldenCreative
Copy link

HoldenCreative commented Nov 10, 2015

Thank you, this solved a major issue I was having with IIS and the subdirectory / pathing not resolving correctly on an Windows Azure wordpress multisite instance.

@CoastalData
Copy link

CoastalData commented May 17, 2017

I had to add my own Rule 7 to fix an issue with multi-site; I just copied Rule 4, which I also modified to fix errors.

<rule name="WordPress Rule 4" stopProcessing="true"> <match url="^([_0-9a-zA-Z-]+/)?(wp-(login|profile|user-edit|content|admin|includes).*)" ignoreCase="false" /> <action type="Rewrite" url="{R:2}" /> </rule>

<rule name="WordPress Rule 7" stopProcessing="true"> <match url="^([_0-9a-zA-Z-]+/)?(site-(new|login|profile|user-edit|content|admin|includes).*)" ignoreCase="false" /> <action type="Rewrite" url="{R:2}" /> </rule>

@Buliwyfa
Copy link

Buliwyfa commented Jan 10, 2018

@CoastalData thanks for the fixed rule 4 worked for me ;)

@phillipecw
Copy link

phillipecw commented Jan 16, 2020

Thank you very much for this. I've spent hours looking for a solution.

@oidacra
Copy link

oidacra commented Mar 31, 2020

Still working 6 year later. Thanks.

@alaasalama
Copy link

alaasalama commented May 27, 2022

that works in 2022! thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment