我有以下规则可重定向到网站的根文件夹中的 www 和 https :
<rewrite>
<rule name="Towww" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="example.com" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" />
</rule>
<rule name="Force HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" />
</rule>
</rewrite>
在 myfolder 子目录中,我具有单独的web.config ,并且我想取消上述两个规则。以下代码无法正常工作,所有内容都重定向到 https 和 www ,例如http://example.com/myfolder仍重定向到https://www.example.com
<rewrite>
<rules>
<remove name="Towww" />
<remove name="Force HTTPS" />
</rules>
</rewrite>
编辑:我发现此解决方案可在父文件夹中设置配置规则,以防止子文件夹从根继承。但我只想使用自己的web.config
排除特定文件夹中的规则,而不要排除父文件夹中的常规规则。
<location path="." inheritInChildApplications="false">
<system.webServer>
<!-- ... -->
</system.webServer>
</location>