How to create a EXCEPT Rewrite Rule at IIS

一笑奈何 提交于 2020-01-17 03:01:27

问题


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

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.

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

Thanks!

Best Regards,

Andre Mesquita


回答1:


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>


来源:https://stackoverflow.com/questions/30110710/how-to-create-a-except-rewrite-rule-at-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!