IIS 8.5 disable rewrite rule for virtual directory

只谈情不闲聊 提交于 2019-12-25 08:04:04

问题


I have a rewrite rule for my "Default Web Site" (aka at my wwwroot's web.config) to redirect all HTTP request to HTTPS as follows:

<rule name="http to https" enabled="true" stopProcessing="true">
  <match url="(.*)" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTPS}" pattern="^OFF$" />
  </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>

Now I want to disable or exclude a Virtual Directory under this so I can reach that only with HTTP. How to do this?

What I have tried: Creating a rule that matches the virt.dir's name, and chose to stop any further action (no success):

<rule name="testsite no https" enabled="true" stopProcessing="true">
  <match url="(testsite)" ignoreCase="true" />
  <action type="None" />
  <conditions>
    <add input="{URL}" pattern="(testsite)" />
  </conditions>
</rule>

Added a negate condition for the first rule (no success)

 <add input="{URL}" pattern="(testsite)" negate="true" />

What am I doing wrong?


回答1:


You do not need a separate rule for that.

  1. Open IIS manager expand the site and select the virtual directory.
  2. In the center pane you can see all the modules. Double click URL Rewrite.
  3. Select the redirect rule and in the actions pane click disable rule.

Also you can add a web.config in your virtual directory and do below

<system.webServer>
    <rewrite>
      <rules>
        <remove name="testsite no https" />
      </rules>
    </rewrite>
</system.webServer>

Or

Change your match condition from <match url="(.*)" /> to <match url="^((?!testsite).)*$" /> so basically this will work for all URLS except the one containing testsite.

Hope this helps.



来源:https://stackoverflow.com/questions/39445929/iis-8-5-disable-rewrite-rule-for-virtual-directory

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