[英]Conditoinal HTTP redirect IIS 7
目前,我将所有http请求重定向到HTTPS,但现在我想添加以下条件:如果URL包含“ admin”,然后将HTTP请求重定向到HTTPS,我如何更改规则以实现此目的(例如http://www.example .com / admin / index.html )?
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
将网址格式更改为:
<match url=".*admin/.*" />
这似乎与IIS模式匹配工具中的示例数据匹配。
要匹配其他部分,例如个人资料,您可以更改正则表达式:
<match url=".*(admin|profile)/.*" />
如果总是以admin
或profile
开头,则可以将正则表达式收紧为^(admin|profile)/.*
( ^
表示模式的开始,请参阅在此屏幕上定义模式 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.