IIS重写规则组合-重定向到更改的域名,删除主机名前缀重定向到ssl

IIS重写规则组合-重定向到更改的域名,删除主机名前缀重定向到ssl,iis,url-rewriting,url-redirection,http-redirect,Iis,Url Rewriting,Url Redirection,Http Redirect,我的IIS网站目前被访问为,我有3个与url重写相关的目标: 重定向到网站的新名称mynewwebsite.com 删除www前缀(如www.mywebsite.com->mywebsite.com或www.mynewwebsite.com-->mynewwebsite.com 重定向到SSL 总之,我想将所有入站请求重定向到任意对象* 必须说明的输入案例包括 任何事* 任何事* 任何事* 任何事* 任何事* 任何事* 任何事* 我的重写规则如下所示: <rewrite> &

我的IIS网站目前被访问为,我有3个与url重写相关的目标:

  • 重定向到网站的新名称mynewwebsite.com
  • 删除www前缀(如www.mywebsite.com->mywebsite.com或www.mynewwebsite.com-->mynewwebsite.com
  • 重定向到SSL
  • 总之,我想将所有入站请求重定向到任意对象*

    必须说明的输入案例包括

    • 任何事*
    • 任何事*
    • 任何事*
    • 任何事*
    • 任何事*
    • 任何事*
    • 任何事*
    我的重写规则如下所示:

    <rewrite>
      <rules>
        <rule name="Do stuff" enabled="true">
          <match url="(.*)" ignoreCase="false" />
          <conditions logicalGrouping="MatchAny">
            <add input="{HTTPS}" pattern="off" />
            <add input="{HTTP_HOST}" pattern="mywebsite.com" />
            <add input="{HTTPS}" pattern="^www.mynewwebsite\.com$" />
          </conditions>
          <action type="Redirect" url="https://mynewwebsite.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
    
    
    任何事*

    我已经对这个问题进行了充分的讨论,以至于我质疑我对规则定义如何工作的基本理解

    • 任何东西都可能存在或根本不存在

    我得出了以下有效的规则,但恐怕这是巧合,而不是我真正理解发生了什么。欢迎评论

    <rewrite>
      <rules>
        <rule name =" Force HTTPS" enabled="true">
          <match url =" (.*)" ignoreCase= "false " />
          <conditions logicalGrouping =" MatchAny" >
            <add input =" {HTTP_HOST}" negate="true" pattern =" ^mynewwebsite\.com$" />
            <add input =" {HTTPS}" pattern= "^www.mynewwebsite\.com$ " />
            </conditions>
          <action type =" Redirect" url= "https://mynewwebsite.fm/{R:1} " appendQueryString="true" redirectType =" Permanent" />
        </rule>
      </rules>
    </rewrite>