Skip to content

Instantly share code, notes, and snippets.

@misaxi
Created September 28, 2014 10:20
Show Gist options
  • Save misaxi/67cb1444a7dccf11f7fa to your computer and use it in GitHub Desktop.
Save misaxi/67cb1444a7dccf11f7fa to your computer and use it in GitHub Desktop.
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

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

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

@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

that works in 2022! thanks!

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