WordPress + Web.config “not found” error on home page

I was trying to setup wordpress on IIS when i faced this problem. I placed a web.config file with given xml code and pretty urls (permalinks) worked fine on all page except the home page. Home page gave a Not Found error while pretty permalinks worked find on all other pages. After adding the following code (given below) in system.webServer settings to web.config it worked find. In short the code given below adds index.php as a default document root.

[xml]<defaultDocument>
<files>
      <remove value="index.php" />
      <add value="index.php" />
   </files>
</defaultDocument>[/xml]

After adding the above code my working web.config looked like:

[xml]<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
      <defaultDocument>
         <files>
            <remove value="index.php" />
            <add value="index.php" />
       </files>
    </defaultDocument>
<rewrite>
       <rules>
          <rule name="wordpress" patternSyntax="Wildcard">
             <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" />
            </rule>
         </rules>
      </rewrite>
</system.webServer>
</configuration>[/xml]

Leave a Reply