iis url将http重定向到非www https [英] iis url redirect http to non www https

查看:139
本文介绍了iis url将http重定向到非www https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重定向

www.domain.de https://domain.de
-works

www.domain.de to https://domain.de -works

http://www.domain.de https://domain.de
-works

http://www.domain.de to https://domain.de -works

http://domain.de https:/ /domain.de
-does not work

http://domain.de to https://domain.de -does not work

rewrite>
  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions logicalGrouping="MatchAll">
        <add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
      </conditions>
      <action type="Redirect" url="https://{C:1}/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>


推荐答案

我认为这对您有用,搜索模式有可选的www和重定向使用后向引用C:2,规则有条件只对非https运行。

I think this will work for you, the search pattern has the optional www and redirects using the back reference C:2, the rule has a condition to only run against non https.

这是模式:

"^(www\.)?(.*)$"

其中:

{C:0} - www.domain.de
{C:1} - www.
{C:2} - domain.de

这是完整的规则:

  <rewrite>
    <rules>
      <rule name="SecureRedirect" stopProcessing="true">
        <match url="^(.*)$" />
        <conditions>
          <add input="{HTTPS}" pattern="off" />
          <add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" />
        </conditions>
        <action type="Redirect" url="https://{C:2}" redirectType="Permanent" />
      </rule>
    </rules>
  </rewrite>

这篇关于iis url将http重定向到非www https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆