[英]Rewrite rule error: HTTP Error 500.50 - URL Rewrite Module Error. The expression “https://abc.com/{R:1}” cannot be expanded
Whenever someone makes request over HTTP protocol I rewrite the url to make it HTTPS. 每当有人通过HTTP协议发出请求时,我都会重写该URL以使其成为HTTPS。 This is the code in web.config:
这是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>
However when I browse on http:// I get IIS error 但是,当我在http://上浏览时,出现IIS错误
HTTP Error 500.50 - URL Rewrite Module Error.
HTTP错误500.50-URL重写模块错误。 The expression
"https://abc.com/{R:1}"
cannot be expanded.表达式
"https://abc.com/{R:1}"
不能扩展。
How can I resolve this? 我该如何解决? I am utterly confused.
我完全感到困惑。
The matches are zero based. 匹配从零开始。
<action type="Rewrite" url="https://abc.com/{R:1}" />
Won't work because you only have one match. 无法正常运作,因为您只有一场比赛。 You need:
你需要:
<action type="Rewrite" url="https://abc.com/{R:0}" />
Also, this won't work, because you can only match on the path below the site root. 此外,这将不起作用,因为您只能在网站根目录下的路径上进行匹配。
<match url="^(?!https://).*" ignoreCase="false" />
It looks like you are checking for ssl. 看来您正在检查ssl。 Try this instead:
尝试以下方法:
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
You can redirect through web config to Hope it will help full 您可以通过Web配置重定向到希望它对您有所帮助
<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^abc.com$" />
</conditions>
<action type="Redirect" url="http://www.abc.com/{R:0}" redirectType="Permanent" />
</rule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.