web.config for WordPress on IIS

If you are hosting a wordpress site on a Windows Server with IIS 7/8, chances are that once you migrate the site it will throw an 400 – Not Found error. This is because IIS is not configured to server php pages by default. If you add an index.php to the end of your url, the site will show up.

To resolve this, create a file called web.config in the root directory of your wordpress installation and add the following text:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>

<remove value="index.php" />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="WPurls" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Leave a Reply

Your email address will not be published. Required fields are marked *