如何在IIS中创建EXCEPT重写规则

lsmd5eda  于 2023-01-26  发布在  其他
关注(0)|答案(1)|浏览(135)

我有一个IIS站点,其重写规则将所有请求重定向到HTTPS。
我有一个使用HTTP的内部Web服务,但重写规则将“http”请求修改为“https”。当Web服务返回错误“对象已移动”时。我尝试使用“AllowAutoRedirect”的真值,但它不起作用。
如何创建EXCEPT重写规则来访问此Web服务?如何使Web服务与HTTPS协议一起工作?

kqlmhetl

kqlmhetl1#

一种方法是在“全局重定向”之前添加规则,并确保使用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>

相关问题