asp.net-core - 在 IIS 上的 ASP.NET Core 应用程序中将 HTTPS 站点重定向到非 www
问题描述
我不想更改我的代码是否有任何解决方案可以通过 IIS 将 HTTPS 站点重定向到 ASP.NET Core 应用程序中的非 www?IIS上有什么解决方案吗?
解决方案
使用 IIS URL Rewrite 模块将以下内容添加到您的 web.config:
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
如果使用 ASP.NET Core 2.1,您可以使用UseHttpsRedirection中间件。
推荐阅读
- python - Seaborn - 将x轴移动到顶部
- html - Flexbox 在折叠其他部分后不允许滚动区域
- react-native - 如何将气球(点)放入谷歌地图应用程序
- python - 使用 pytesseract 和 opencv 对删除文本进行 OCR
- android - 在android上创建对webservice的多个请求
- javascript - 使用javascript更改其他页面中复选框的选中状态时,DataTable会一直返回第一页
- angular - Angular - 存储永久用户信息的位置(本地存储除外)
- azure - azure 数据结构中复制数据中的列分隔符错误
- java - 使用 apache poi 创建 ms word 文档时出现重复的页眉/页脚问题
- sql - 选择期间保持锁定