Redirect domain1.co.uk/some_subs to domain2.co.uk/different_subsRSS

3 replies

Last post Feb 07, 2020 01:51 PM by Rovastar

  • Redirect domain1.co.uk/some_subs to domain2.co.uk/different_subs

    Feb 07, 2020 10:37 AM|LukaszD|LINK

    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

  • Rovastar Rovastar

    5486 Posts

    MVP

    Moderator

    Re: Redirect domain1.co.uk/some_subs to domain2.co.uk/different_subs

    Feb 07, 2020 11:03 AM|Rovastar|LINK

    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.
    Troubleshoot IIS in style
    https://www.leansentry.com/
  • Re: Redirect domain1.co.uk/some_subs to domain2.co.uk/different_subs

    Feb 07, 2020 11:29 AM|LukaszD|LINK

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

  • Rovastar Rovastar

    5486 Posts

    MVP

    Moderator

    Re: Redirect domain1.co.uk/some_subs to domain2.co.uk/different_subs

    Feb 07, 2020 01:51 PM|Rovastar|LINK

    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.

    Troubleshoot IIS in style
    https://www.leansentry.com/