Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple domain pointing root folder need to point subfolders according to domain name in web.config

I have three domains domain1.com, domain2.com and domain3.com all re pointing to my azure web app mysites.azurewebsite.net. In my root folder of azure website three folders available domain1, domain2 and domain3 with wordpress installed on these folders. Currently i have given below settings in my web.config and it is pointing to corresponding folders.

           <rule name="domain1" stopProcessing="true">
                <match url=".*"/>
                    <conditions logicalGrouping="MatchAny">
                        <add input="{HTTP_HOST}" pattern="^(www.)?domain1.com"/>
                    </conditions>
                <action type="Rewrite"  redirectType="Permanent" url="\domain1\{R:0}" />
            </rule>
             <rule name="domain2" stopProcessing="true">
                <match url=".*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^(www.)?domain2.com" />
                        <add input="{PATH_INFO}" pattern="^/domain2/" negate="true" />
                    </conditions>
                <action type="Rewrite" url="\domain2\{R:0}" />
            </rule>
             <rule name="domain3" stopProcessing="true">
                <match url=".*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^(www.)?domain3.com" />
                        <add input="{PATH_INFO}" pattern="^/domain3/" negate="true" />
                    </conditions>
                <action type="Rewrite" url="\domain3\{R:0}" />
            </rule>

Issue i am facing is while i am clicking on any sub-page link it will show below error

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

When i am disabling user friendly url (permalink) from my wordpress admin, then it works fine. But it shows like mydomain.com/?page_id=1 for About us page.

How can i make it work after permalink changed to user friendly url like mydomain1.com/about-us

Not working because of each sub folder have wordpress and in wordpress i have enabled permalink. Otherwise it works fine

like image 731
JSunny Avatar asked Jul 24 '15 18:07

JSunny


1 Answers

I don't have a full answer for you, but the stopProcessing="true" on every rule may be causing you some grief, because it stops the rules from being processed further, so your second and third rules will be ignored when you set this flag on the first rule.

You also have your pattern set to match "*\" on all three rules, so perhaps a rule like this could work:

<rules>
   <rule name="Domain2">
      <match url="*.domain2.*" />
      <conditions>
         <add input="{UrlDecode:{QUERY_STRING}}" pattern="domain2" />
      </conditions>
      <action type="Rewrite" url="{HTTP_HOST}/domain2/" />
   </rule>
</rules>
like image 101
Ingytron Avatar answered Sep 22 '22 17:09

Ingytron