c# - 重写规则不适用于从 http 到 https 的重定向
问题描述
尝试了下面的代码,但它不起作用,在 c# 的 web.config 文件的 system.webServer 标签中输入了 rewrite 标签,显示错误 rewrite can not be child element of system.webServer 标签,我也在 IIS 中配置了这个规则
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rule1" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
解决方案
如果没有使用 Web 平台安装程序安装 Urlrewrite 模块,请安装它,并尝试使用 urlrewrite 模块手动添加规则。
https://www.iis.net/downloads/microsoft/web-platform-installer
https://www.iis.net/downloads/microsoft/url-rewrite
问候,贾尔帕。
推荐阅读
- ssl - Traefik:无法获取域的 ACME 证书
- java - Selenium java 错误 com/google/common/collect/ImmutableMap 在 ubuntu
- javascript - 如何在d3柱形图中在y轴上绘制水平线?
- xamarin - NotifyDataSetChanged() Xamarin.Android 的奇怪行为
- collada - dae 到 gltf pbr 导出不导出纹理不是 base64
- dart - Flutter 的认证库
- python - 使用 Python 从包含多组数据的文件中读取指定列
- haskell - `~`(波浪号)在实例上下文中是什么意思,为什么在某些情况下需要解决重叠问题?
- python - Python SQL - 一直说“索引 81 处不支持的格式字符 'f' (0x66)”,即使所有属性的类型都是正确的
- passport.js - 更新nestjs/graphql后不传递标头