Friday, April 05, 2013

Running WordPress on IIS Server

Earlier, I had faced a problem while running WordPress on a GoDaddy server which runs on IIS. The homepage was coming properly but other permalinks were mostly giving 404 error. Thank god, the admin panel was opening. I had tried rebuilding the permalinks from Settings>Permalinks option which actually modifies the .htaccess did not help because on IIS sever, .htaccess file remains inactive. Rebuilding permalinks showed me one message saying "You need to update web.config file" which reminded me of the fact that the substitute for .htaccess on IIS server is web.config file which resides at the root folder, similar to where .htaccess is placed on an Apache server. I got the following code after googling a bit regarding the web.config, and once I put the new web.config file with the content shown below everything simply changed back to normal. This is worth checking ...

<?xml version="1.0"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Main Rule" 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" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

No comments: