如何在IIS中创建EXCEPT重写规则 [英] How to create a EXCEPT Rewrite Rule at IIS

查看:108
本文介绍了如何在IIS中创建EXCEPT重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有重写规则"的IIS站点,可将所有请求重定向到https.

I have a IIS Site with Rewrite Rule to redirect all requests to https.

我有一个内部Web服务,可与http一起使用,但重写规则将"http"请求修改为"https".发生这种情况时,Web服务将返回错误对象已移动".我尝试使用具有真实值的"AllowAutoRedirect",但不起作用.

I have a internal webservice which works with http but rewrite rule modify "http" request to a "https". When happens, webservice returns an error "Object Moved". I tried use "AllowAutoRedirect" with true value but it doesn't work.

如何创建一个EXCEPT重写规则来访问此Web服务或如何使Web服务与https协议一起工作?

How to create a EXCEPT Rewrite Rule to access this webservice ou how to make webservice work with https protocol?

谢谢!

最好的问候,

安德烈·梅斯基塔

推荐答案

一种方法是在全局重定向"之前添加规则,并确保使用 stopProcessing ="true" ,以便未执行下一条规则,例如,以下规则仅允许对"foo/"段的请求使用HTTP,其他所有内容都将重定向到SSL:

One way is to add the rule before the "global redirect" and make sure to use stopProcessing="true" so that the next rule is not executed, for example the following rule will allow HTTP only on requests to the segment "foo/", everything else will redirect to 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>

这篇关于如何在IIS中创建EXCEPT重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆