gpt4 book ai didi

asp.net - 重写规则错误 : HTTP Error 500. 50 - URL 重写模块错误。表达式 "https://abc.com/{R:1}"无法展开

转载 作者:行者123 更新时间:2023-12-03 14:54:43 25 4
gpt4 key购买 nike

每当有人通过 HTTP 协议(protocol)发出请求时,我都会重写 url 以使其成为 HTTPS。这是 web.config 中的代码:

<rule name="Imported Rule 1-1" enabled="true" stopProcessing="true">
<match url="^(?!https://).*" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{SERVER_PORT}" pattern="80" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="https://abc.com/{R:1}" />
</rule>

但是,当我在 http://上浏览时,我得到 IIS 错误

HTTP Error 500.50 - URL Rewrite Module Error. The expression "https://abc.com/{R:1}" cannot be expanded.



我该如何解决这个问题?我完全糊涂了。

最佳答案

匹配是从零开始的。

<action type="Rewrite" url="https://abc.com/{R:1}" />

行不通,因为你只有一场比赛。你需要:
<action type="Rewrite" url="https://abc.com/{R:0}" />

此外,这也行不通,因为您只能在站点根目录下的路径上进行匹配。
<match url="^(?!https://).*" ignoreCase="false" />

看起来您正在检查 ssl。试试这个:
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>

关于asp.net - 重写规则错误 : HTTP Error 500. 50 - URL 重写模块错误。表达式 "https://abc.com/{R:1}"无法展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6916407/

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