我的web.config中有一个重写规则,强制所有页面转到https。 有没有办法排除单个页面。
例如,我是否希望http://www.example.com/thispage.ashx重定向到https,如何修改规则以排除它?
<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="Permanent" />
</rule>
答案 0 :(得分:0)
您可以创建一个与/thispage.ashx
以外的所有网址匹配的附加条件。
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{URL}" pattern="^/thispage\.ashx$" negate="true" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
注意:要测试新规则,请确保已清除浏览器正在处理的网站的缓存。否则,您可能无法测试规则是否正常,因为客户端缓存的重定向响应。