Question

Why isn't this rule working when I go to a browser with the URL rewrite module?
It works on the regex tester with the url rewrite module.
I even put it at the top of all my rules.

Example url: organizations/51/middle-tennessee-basketball-showcases-basketball-tournaments?page=1

Rewrite rule:

<rule name="Organization Redirect" stopProcessing="true">
    <match url="^organizations/(.*)-basketball-tournaments\?page=1$" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
    <action type="Redirect" url="organizations/{R:1}" appendQueryString="false" />
</rule>
Was it helpful?

Solution

Your rule should be as following:

<rule name="Organization Redirect" stopProcessing="true">
    <match url="^organizations/(.*)-basketball-tournaments$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="^page=1$" />
    </conditions>
    <action type="Redirect" url="organizations/{R:1}" appendQueryString="false" />
</rule>

You should not check the query string (here page=1) in the url test but in the conditions section.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top