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"?>
<defaultDocument enabled="true">

<remove value="index.php" />
<add value="index.php" />
<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" />
<action type="Rewrite" url="index.php/{R:0}" />

Leave a Reply

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