0
votes

I have a one website application pointing multiple domains.

what i want is, if user visiting domain1.com then they should be redirect to https://www.domain1.com

and rest all domain pointing same application use without https (e.g http://www.domain2.com / http://www.domain3.com)

Domain must redirect as below:

  1. domain1.com > https://www.domain1.com
  2. domain2.com > http://www.domain2.com (rewrite as below code)
  3. domain3.com > http://www.domain3.com (rewrite as below code)

Below code to rewrite for other than https domains.

<rule name="domain1" stopProcessing="true">
   <match url="^www.domain1.com$" negate="true" />          
   <action type="Rewrite" url="otherdomain/{R:1}" />
</rule>

Appriciate your help in advance. Thanks

1

1 Answers

0
votes

Can you please try below configuration?

<rules>
    <rule name="Remove WWW prefix" stopProcessing="true">
      <match url="(.*)" ignoreCase="true" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^www\.domain1\.com$" />
      </conditions>
      <action type="Redirect" url="https://www.domain1.com/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>