write <rewrite> for wordpress site in web.config in IIS server

I have installed wordpress in IIS server(window server 64bit R2 standerd edition).
I have to write rules in its web.config file for running wordpress site succesfully. When I am trying to add any rules in web.config file, I got an error of 500: Internal server error.

here is my code of web.config file:

Read More
<?xml version="1.0" encoding="UTF-8"?><configuration>
<system.webServer>
    <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>
<httpErrors>  
  <remove statusCode="404" subStatusCode="-1" />  
  <error statusCode="404" prefixLanguageFilePath=""  path="/index.php?error=404"  responseMode="ExecuteURL" />  
</httpErrors>
<staticContent>
        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
        <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
        <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />

    </staticContent>
</system.webServer></configuration>

If i remove tag, it is working but other part is not working of site(like add to cart and checkout process, etc.).

So, how can I write in web.config file.

Thanks,
Ketan

Related posts

Leave a Reply

3 comments

  1. I got my answer, actually in IIS server rewrite module is disable by default. We have to enable it to use write rules in web.config. after enable this module, my site is working perfectly. hope this can help someone.

  2. Your best bet is to backup & remove your web.config file, then use WordPress permalinks page to generate the web.config file for you. Lastly, add incrementally what you need that WordPress does not do for you.

  3. USE these rule , on IIS

            <rule name="Imported Rule 1" stopProcessing="true">
                <match url="^index.php$" ignoreCase="false"/>
                <action type="None"/>
            </rule>
    
            <rule name="Redirect Image to HTTP" stopProcessing="true">
                <match url=".*.(gif|jpg|jpeg|png|css|js)$" ignoreCase="true"/>
                <action type="Rewrite" url="{R:0}"/>
            </rule>
    
            <rule name="Imported Rule 2" stopProcessing="true">
                <match url="." ignoreCase="false"/>
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
                </conditions>
                <action type="Rewrite" url="/index.php"/>
            </rule>
    
        </rules>