asp.net - Web 配置重写规则以在多租户应用程序上强制 http 到 https
问题描述
我有一个多租户门户系统,但重写规则不适用于多种条件
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="^(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{HTTPS1}" pattern="^(website1\.com|www\.website1\.com)$" />
<add input="{HTTPS2}" pattern="^(website2\.com|www\.website2\.com)$" />
<add input="{HTTPS3}" pattern="^(website3\.com|www\.website3\.com)$" />
<add input="{HTTPS4}" pattern="^(website4\.com|www\.website4\.com)$" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
我希望当我在我的网络浏览器上访问http://portal.website1.com时,该程序应该将我带到https://portal.website1.com并为 portal.website2.com、门户做同样的事情。 website3.com,portal.website4.com
但它仅适用于 portal.website2.com 和 portal.website3.com ,它不会在 portal.website1.com 和 portal.website4.com 上强制使用 https
解决方案
试试这个system.WebServer
:
<system.webServer>
....
<rewrite>
<rules>
<rule name="Force HTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URO}" redirectType="Temporary" />
</rule>
</rules>
</rewrite>
</system.webServer>
推荐阅读
- c - Pthread 无法正常工作。c编程
- c# - 如何通过 Unity 中的脚本更改面板的颜色/透明度?
- javascript - Swift/Firebase:无法在 Firebase 云函数上发送请求数据
- python - 将 float 和 int 类型的秒数添加到日期
- sql - 如何在 TOAD 中同时运行两个 ORACLE SQL 查询?
- javascript - 无法检查字符串 JS 中正斜杠 / 之前是否有空格
- javascript - 捕获异常的 Mocha 未捕获错误
- kotlin - 为什么这个函数返回正确的二叉树高度?
- command - ddl -p9 apppackagename.zip *unzip=apppackagename.zip 命令的含义
- monorepo - 如何从每个包中提取通用 devDependencies 到根 package.json 文件?