IIS 将规则重写为路径
IIS rewrite rule to path
因为 AspNetCore MVC 无法像 host//querystring
那样匹配 Url 。我想使用 IIS 重写模块重定向下面的 URL
https://localhost:5001//?id=123 to https://localhost:5001/?id=123
这是我的规则,但它不起作用,我该如何改进它?
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="redirect // to /">
</rewriteMap>
</rewriteMaps>
<rules>
<clear />
<rule name="Redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)//\?(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="{R:1}/?{R:2}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
据我所知,无论您在地址栏中输入多少个“/”,Web 浏览器和fiddler 只会向IIS 端发送单个“/”。
即使您可以向 IIS 发送 http://localhost// 这样的请求。匹配 url 是 /。所以 (.)//\?(.) 永远不会匹配您的传入请求 URL.
因为 AspNetCore MVC 无法像 host//querystring
那样匹配 Url 。我想使用 IIS 重写模块重定向下面的 URL
https://localhost:5001//?id=123 to https://localhost:5001/?id=123
这是我的规则,但它不起作用,我该如何改进它?
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="redirect // to /">
</rewriteMap>
</rewriteMaps>
<rules>
<clear />
<rule name="Redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)//\?(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="{R:1}/?{R:2}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
据我所知,无论您在地址栏中输入多少个“/”,Web 浏览器和fiddler 只会向IIS 端发送单个“/”。
即使您可以向 IIS 发送 http://localhost// 这样的请求。匹配 url 是 /。所以 (.)//\?(.) 永远不会匹配您的传入请求 URL.