Azure IIS重写规则

Azure IIS重写规则,azure,iis,url-rewrite-module,Azure,Iis,Url Rewrite Module,我发现了两种不同的重写规则来强制IIS托管网站使用HTTPS。我有一个网站将托管在Azure应用程序服务上,该服务将使用此规则 备选案文1: <rewrite> <rules> <rule name="Force HTTPS" enabled="true"> <match url="(.*)" ignoreCase="false" /> <conditions> <add inp

我发现了两种不同的重写规则来强制IIS托管网站使用HTTPS。我有一个网站将托管在Azure应用程序服务上,该服务将使用此规则

备选案文1:

<rewrite>
  <rules>
    <rule name="Force HTTPS" enabled="true">
      <match url="(.*)" ignoreCase="false" />
      <conditions>
        <add input="{HTTPS}" pattern="off" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

备选案文2:

<rewrite>
  <rules>
    <rule name="Redirect to https">
      <match url="(.*)"/>
      <conditions>
        <add input="{HTTPS}" pattern="Off"/>
        <add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent"/>
    </rule>
  </rules>
</rewrite>

问题:

  • 选项1中ignoreCase设置为false的原因是什么
  • REQUEST_方法输入是否将安全性限制为只获取并进入选项2
  • appendQueryString=“true”是否在重定向时保留查询字符串
  • 有没有其他的选择来考虑这不是其中的一部分?
    我建议阅读官方文件:

    您可以在“所有属性”解释中找到它

    • ignoreCase–使用此属性控制条件的模式匹配应区分大小写还是不区分大小写

    • appendQueryString–指定在替换过程中是否应保留当前URL中的查询字符串。默认情况下,如果未指定AppendQueryString标志,则假定该标志为TRUE。这意味着原始URL中的查询字符串将附加到替换的URL


    感谢您的链接。知道REQUEST\u方法条件的作用吗?它似乎限制了重定向到GET和HEAD请求。这是对Http_方法的限制(仅当Http_方法是GET o HEAD时重定向),我认为第一个选项更好。