Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
web.config for IIS hosted multi-site WordPress
<!-- -->
<?xml version="1.0" encoding="UTF-8"?>
<rule name="WordPress Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false" />
<action type="None" />
<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 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 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" />
<action type="None" />
<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 name="WordPress Rule 6" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
<action type="Rewrite" url="{R:2}" />
<rule name="WordPress Rule 7" stopProcessing="true">
<match url="." ignoreCase="false" />
<action type="Rewrite" url="index.php" />
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.

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>

Copy link

Buliwyfa commented Jan 10, 2018

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

Copy link

phillipecw commented Jan 16, 2020

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

Copy link

oidacra commented Mar 31, 2020

Still working 6 year later. Thanks.

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