【发布时间】:2019-08-03 01:19:36
【问题描述】:
尝试了下面的代码但它不起作用,在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.config,删除任何敏感信息?
-
你在IIS中安装了URL重写模块吗?
-
@MatthewEvans 我已经在 IIS 中安装了 URL 重写模块并且已经配置了它
-
@ColinM 这是来自网络配置的示例代码:
...rule ... -
第一件事,把它放在你的问题中,而不是评论中。其次,您是否尝试过通过 IIS 管理控制台 -> URL Rewrite 配置此规则?
标签: c# iis url-rewrite-module