0
votes

Beacuse of AspNetCore MVC cannot match up Url like host//querystring . I want to redirect the URL below using IIS Rewrite module https://localhost:5001//?id=123 to https://localhost:5001/?id=123 This is my rule,but it not work,how can i improve it?

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

enter image description here

1

1 Answers

0
votes

As far as I know, Web browser and fiddler will only send single "/" to IIS side no matter how many "/" you input in the address bar.

Even if you can send a request like http://localhost// to IIS. The match url is /. So (.)//\?(.) will never match your incoming request URL.