从www https重定向到非www https web.Config

时间:2018-08-26 18:28:50

标签: asp.net redirect model-view-controller https web-config

如果您输入了www.example.comhttp://example.com,那么我的代码非常有效-它会重定向到https://example.com

现在,当我输入https://www.Example.com时,我想重定向到https://Example.com-但这不适用于此重定向系统。

  <rewrite>
      <rules>
        <rule name="Redirect to non-www" stopProcessing="true">
          <match url="(.*)" negate="false"></match>
          <action type="Redirect" url="https://Example.com/{R:1}"></action>
          <conditions>
            <add input="{HTTP_HOST}" pattern="^Example\.com$" negate="true"></add>
          </conditions>
        </rule>


         <rule name="HTTP to HTTPS redirect" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions> 
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions> 
    <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
          </rule>

      </rules>
    </rewrite>

0 个答案:

没有答案