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″?>
<rule name=”CanonicalHostNameRule1″>
<match url=”(.*)” />
<add input=”{HTTP_HOST}” pattern=”^$” negate=”true” />
<action type=”Redirect” url=”{R:1}” />
<rule name=”Main Rule”>
<match url=”.*” />
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
<action type=”Rewrite” url=”index.php/{R:0}” />

-Cheers Spencer