【问题标题】:How to create a EXCEPT Rewrite Rule at IIS如何在 IIS 中创建 EXCEPT 重写规则
【发布时间】:2015-05-07 20:06:47
【问题描述】:
我有一个带有重写规则的 IIS 站点,用于将所有请求重定向到 https。
我有一个使用 http 的内部网络服务,但重写规则将“http”请求修改为“https”。发生时,webservice 返回错误“对象已移动”。我尝试使用具有真实值的“AllowAutoRedirect”,但它不起作用。
如何创建一个 EXCEPT 重写规则来访问这个 web 服务或者如何让 web 服务使用 https 协议?
谢谢!
最好的问候,
安德烈·梅斯基塔
【问题讨论】:
标签:
web-services
iis
ssl
url-rewriting
windows2012
【解决方案1】:
一种方法是在“全局重定向”之前添加规则并确保使用 stopProcessing="true" 以便不执行下一条规则,例如以下规则将允许 HTTP只有对“foo/”段的请求,其他所有内容都会重定向到 SSL:
<rewrite>
<rules>
<rule name="Allow requests to the folder foo over non-https" stopProcessing="true">
<match url="^foo/.*" />
<action type="None" />
</rule>
<!-- Else redirect ALL request to HTTPS -->
<rule name="Redirect to https">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="Off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>