url 重写模式中的 ^ON$ 和 ^OFF$ 是什么意思,什么匹配这个模式

What is the meaning of ^ON$ and ^OFF$ in url rewrite pattern and what matches this pattern

我遇到了这条规则:

<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
 <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>

pattern 中的 ON 或 OFF 是什么,什么与此模式匹配?

模式 OFF 确保规则仅在请求通过 http 传入时执行,否则您可能会陷入无限循环。

因此添加一个条件,说明 {HTTPS} 已关闭。

the ^ =(字符串的开头,或者 "negative" 如果在范围的开头)

$ =(字符串结尾)

尽管额外的 start/stop 个字符对于此目的来说似乎是多余的

Here is a blog that discusses inbound rules

input={HTTPS} 可以提供两个输入值,OFF(对于 NO-HTTPS 请求)或 ON(对于 HTTPS 请求)。因此,如果模式值匹配,则执行规则。这就是为什么 pattern="OFF" 确保请求通过 http 传入的原因。因此,规则得到执行。