IIS 8.5禁用虚拟目录的重写规则 [英] IIS 8.5 disable rewrite rule for virtual directory

查看:166
本文介绍了IIS 8.5禁用虚拟目录的重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的默认网站(又名我的wwwroot的web.config)有一个重写规则,将所有HTTP请求重定向到HTTPS,如下所示:

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>

现在我想在此下禁用或排除虚拟目录,这样我才能通过HTTP实现这一目标。怎么做?

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

我尝试过:创建一个与virt.dir名称相匹配的规则,并选择停止任何进一步的操作(不成功):

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" />

我做错了什么?

推荐答案

您不需要单独的规则。

You do not need a separate rule for that.


  1. 打开IIS管理器展开网站并选择虚拟目录。

  2. 在中心窗格中你可以看到所有的模块。双击URL Rewrite。

  3. 选择重定向规则,然后在操作窗格中单击禁用规则。

您还可以在虚拟目录中添加web.config并在下面执行

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>

更改您的匹配条件< match url =(。*)/> < match url =^((?!testsite)。)* $/> 所以基本上这适用于所有网址,但包含测试网站的网址除外。

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

希望这有帮助。

这篇关于IIS 8.5禁用虚拟目录的重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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