我的 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>
您可以创建一个附加条件来匹配除 之外的所有 URL /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>
注意:要测试您的新规则,请确保您已清除您正在处理的网站的浏览器缓存。否则,由于客户端缓存重定向响应,您可能无法测试规则是否有效。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句