IIS重写规则

问题描述 投票:0回答:1

我发现了两种不同的重写规则来强制对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. 在选项1中将ignoreCase设置为false的原因是什么?
  2. 在选项2中,REQUEST_METHOD输入是否将安全性限制为仅GET和HEAD?
  3. appendQueryString =“ true”是否将查询字符串保留在重定向状态?
  4. 是否还有其他选择不属于这两个选择?
azure iis url-rewrite-module
1个回答
1
投票

我建议阅读官方文档:

https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference

您可以找到所有属性说明。

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

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

© www.soinside.com 2019 - 2024. All rights reserved.