gpt4 book ai didi

asp.net - 在与 IIS 8.5 (ASP.NET) 兼容的 WEB.CONFIG 中将 HTTP 重定向到 HTTPS

转载 作者:行者123 更新时间:2023-12-01 00:40:00 25 4
gpt4 key购买 nike

在这里发疯。我有一条规则,从 HTTP 重定向所有页面至HTTPS ,在 IIS8 中工作得很好但我在 IIS 8.5 中收到 500 内部服务器错误。我想我缺少一些配置,但是在搜索了几个小时并尝试了 system.WebServer 中重写规则的各种不同更改后不知所措在 web.config文件。
这是代码(大约 5 种变体之一 - 都不起作用)

<rewrite>
<rules>
<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{SERVER_PORT_SECURE}" pattern="^0$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>

无需简单地将其写入 MasterPage (我可以这样做,但是这该死的东西在升级之前工作得很好),我有什么遗漏吗?也许是配置?

另一个有效的版本(在 IIS8.5 托管的另一个站点上)
<rewrite>
<rules>
<rule name="httpsredirect" 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>

最佳答案

看起来你忘记安装 rewriteurl 模块了。在这里获取:

http://www.iis.net/downloads/microsoft/url-rewrite

关于asp.net - 在与 IIS 8.5 (ASP.NET) 兼容的 WEB.CONFIG 中将 HTTP 重定向到 HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38178405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com