locked
Redirect domain1.co.uk/some_subs to domain2.co.uk/different_subs RRS feed

  • Question

  • User950427332 posted

    Good morning

    I've been tasked with setting some redirections but I can't get subdirectories  to work.

    I've already redirected domain with code. This part works fine

    <rule name="Redirects domain1.co.uk to domain2.co.uk" patternSyntax="ECMAScript" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAny">
    <add input="{HTTP_HOST}" pattern="^(www.)?domain1.(com|co.uk)$" />
    </conditions>
    <action type="Redirect" url="https://www.domain2.co.uk/{R:0}" />
    </rule>

    Now I am trying to redirect some highly ranked subs but I am not getting any luck with below code. Any help would be appreciated.

    <rule name="Subdirectory 1" patternSyntax="ECMAScript" stopProcessing="true">
                <match url=".*" />
                <conditions logicalGrouping="MatchAny">
    				<add input="{HTTP_HOST}" pattern="^(www.)?domain1.(com|co.uk)$" />
    				<add input="{PATH_INFO}" pattern="subdirecotory-A$" />
                </conditions>
                <action type="Redirect" url="https://www.domain2/subdirectory-B/{R:0}" />
            </rule>

    Lukasz

    Friday, February 7, 2020 10:37 AM

All replies

  • User-2064283741 posted
    You want to Match All conditions rather than MatchAny.

    And if this is the same domain you are redirecting too you will need your subdirectory rule above your general one.
    Friday, February 7, 2020 11:03 AM
  • User950427332 posted

    I've changed MatchAny to MatchAll but still no luck. I am redirecting to different domain and different sub-directory. 

    Friday, February 7, 2020 11:29 AM
  • User-2064283741 posted

    meant to say redirecting from.

    A quick look those were the things that stood out. I suppose if you have something cached it could cause unexpected results so try from a new browser.

    The best way is to trace though this and see what is being triggered and why.

    https://forums.iis.net/t/1193146.aspx?Rule+not+working+as+expected+Use+Failed+Request+Tracing

    It become a lot clearer then to what is wrong and how to fix it.

    Friday, February 7, 2020 1:51 PM