Rewrite WordPress paramlink in web.config not working for secondary domain over IIS 8

WordPress sites hosted over IIS 8, one main domain and one another domain. Let’s say: maindomain.com and anotherdomain.com.

physical path: acb/maindomain (for main domain) and
physical path: acb/maindomain/anotherdomain.com (for another domain)

Read More

maindomain.com working with any paramlink structure.

Below is maindomain.com/web.config file code:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
      <rules>
        <!-- for maindomain -->
        <rule name="maindomain" 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>
             <!-- bellow code point subdomain.com to acb/maindomain/anotherdomain.com site  -->
            <rule name="subdomain.com to sub folder" enabled="true">
                <match url="(.*)" ignoreCase="true"/>
                <conditions logicalGrouping="MatchAll">
                    <add input="{HTTP_HOST}" pattern="^(www.)?subdomain.com$" ignoreCase="false"/>
                </conditions>
                <action type="Rewrite" url="subdomain.com/{R:1}" />
            </rule>
       </rules>
    </rewrite>
  </system.webServer>
</configuration>

Below is subdomain.com/web.config file code:

<?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>
  </system.webServer>
</configuration>

Only issue if I want to access subdomain.com/sub-post-title
not working, it shows maindomain 404 page but url is same. But perfectly working with main domain: maindomain.com/subomain.com/main-post-title.

Related posts