IIS Redirect non-www to www AND http to https

前端 未结 1 714
暗喜
暗喜 2020-12-01 09:54

i\'m trying to implement two rules for IIS to Redirect non-WWW to WWW and http to https.

http://zzz.com -> https://www.zzz.com
http://www.zzz.com -> ht         


        
相关标签:
1条回答
  • 2020-12-01 10:26

    Yes you can merge them into one and use the logicalGrouping for the conditions and set it to Any which would be the equivalent of an "OR". For example:

    <rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAny">
          <add input="{HTTP_HOST}" pattern="^[^www]" />
          <add input="{HTTPS}" pattern="off" />
      </conditions>
      <action type="Redirect" url="https://www.zzz.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>
    
    0 讨论(0)
提交回复
热议问题