2015-06-24 30 views
3

我碰到这条规则来:

<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> 

什么是ON或OFF模式,这是什么模式匹配?

+1

为什么'模式= “^ $ OFF”'而不仅仅是'模式= “关”'? “{https}”可以返回或打开。那么为什么正则表达式边界? –

+0

@RoyiNamir非常好的问题。你有答案吗? –

回答

6

OFF模式确保规则只有在请求通过http进入时才执行,否则可能会以无限循环结束。

因此添加一个条件,指出{HTTPS}关闭。

所述^ =(串的开始,或“负”,如果在一定范围的开始)

的$ =(字符串的末尾)

虽然额外的开始/停止字符似乎是多余的了为此

Here is a blog that discusses inbound rules

+0

非常感谢您的回答 –