【问题标题】:IIS rewrite rule to pathIIS 将规则重写为路径
【发布时间】:2020-09-30 20:58:59
【问题描述】:

因为 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>

【问题讨论】:

    标签: iis url-rewriting url-rewrite-module


    【解决方案1】:

    据我所知,无论您在地址栏中输入多少个“/”,Web 浏览器和提琴手都只会将单个“/”发送到 IIS 端。

    即使您可以向 IIS 发送像 http://localhost// 这样的请求。匹配 url 是 /。所以 (.)//\?(.) 永远不会匹配你传入的请求 URL。

    【讨论】:

      猜你喜欢
      • 2015-08-26
      • 2014-06-27
      • 2020-02-17
      • 1970-01-01
      • 2015-08-17
      • 1970-01-01
      • 2012-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多