Fix 404 Errors in WordPress on IIS7 with PHP
So I just got done setting up my new IIS7 server and I want to move some of my wordpress sites from Apache over to IIS7 with PHP. So I start testing and right away I’m getting 404 – Page not found errors on every page.

Naively, I thought that the IIS7 Url Rewrite module would work like magic! Nope. So you just have to put in some simple rules inside of a web.config file inside your wordpress site directory for the rewrite module to work. (If you haven’t installed the IIS7 Url rewrite module. You would need to do that too, of course.)

Here is some sample code to use for your web.config file. This worked for me. Let me know if it works for you.
(Make sure to change mydomainname to your actual domain name)

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”CanonicalHostNameRule1″>
<match url=”(.*)” />
<conditions>
<add input=”{HTTP_HOST}” pattern=”^www.mydomainname.com$” negate=”true” />
</conditions>
<action type=”Redirect” url=”http://www.mydomainname.com/{R:1}” />
</rule>
<rule name=”Main Rule”>
<match url=”.*” />
<conditions>
<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>

-Cheers Spencer