简体   繁体   中英

URL Rewriting - how to configure multiple domain on same website with http and https

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 (eg 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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM