url-rewriting - 无法清除子文件夹中的重写规则
问题描述
我在网站根目录的 web.config 中有这个规则,它重定向到 HTTPS:
<rewrite>
<rules>
<rule name="HTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" negate="false" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
在一个子文件夹中,我有单独的配置文件,我想清除重定向到 HTTPS,但这个文件夹也重定向到 HTTPS:
<rewrite>
<rules>
<clear />
</rules>
</rewrite>
解决方案
你不能这样做。规则只能存储在 web.config 中定义。您可以将它们放在那里或提供存储规则的文件的路径(但它仍然在 web.config 中定义),如下所示:
<system.webServer>
<rewrite>
<rules configSource="App_Config\RewriteRules.config" />
<outboundRules configSource="App_Config\OutboundRewriteRules.config" />
<rewriteMaps configSource="App_Config\RewriteMaps.config" />
</rewrite>
</system.webServer>
如果您希望某些 URL 不被重定向到 HTTPS,那么您需要创建一个智能规则来检测这一点(或具有一组规则)。
推荐阅读
- postgresql - docker-entrypoint-initdb.d 错误解释器:权限被拒绝
- crystal-reports - 抑制 Crystal Reports 中前两条和最后一条记录之间的分组部分中的记录
- sql - Oracle 动态查询(返回或选择)结果为表
- javascript - 当我在卡片上移动(悬停时)时,卡片的背景和图像在闪烁,当我将鼠标悬停在卡片上并停止移动光标时它工作正常
- java - 如何确定两个字符串在java中是否可置换?
- kubernetes - 网络策略不适用于 daemonset pod
- javascript - 点击时隐藏下拉菜单
- android - Scoped storage / Android 11, targetSdkVersion = 30 / 保存非媒体文件
- node.js - 在向前端发送响应之前将文件保存在服务器上
- android - 从 PlayStore 下载的 Android 应用仍然使用测试模式进行应用内购买