加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – url重写模式中^ ON $和^ OFF $的含义是什么,以及匹配

发布时间:2020-12-16 03:35:22 所属栏目:asp.Net 来源:网络整理
导读:我遇到了这个规则: rule name="Redirect to HTTPS" stopProcessing="true"match url="(.*)" /conditionsadd input="{HTTPS}" pattern="^OFF$" //conditions action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" //rule 模式中
我遇到了这个规则:

<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是什么以及与此模式匹配的是什么?

解决方法

模式OFF是确保仅当请求通过http进入时才执行规则,否则您可能最终处于无限循环中.

因此添加一个条件,说明{HTTPS}为OFF.

^ =(字符串的开头,如果在范围的开头,则为“否定”)

$=(字符串结束)

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

Here is a blog that discusses inbound rules

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读