locked
Domain redirection with subfolder exception RRS feed

  • Question

  • User-20427539 posted

    Hello,
    I have a domain old.dom1.com. I want to redirect all contents of this domain to dom2.com, with one exception. The URL old.dom1.com/exception should not be redirected.
    Is this possible and if so how?
    I have already tried this:

    <rewrite>
                <rules>
                    <rule name="CanonicalHostNameRule" enabled="true" stopProcessing="true">
                        <match url=".*" negate="false" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{HTTP_HOST}{REQUEST_URI}{URL}" pattern="exception/*" negate="true" />
                        </conditions>
                        <action type="Redirect" url="https://dom2.com" appendQueryString="false" />
                    </rule>
                </rules>
            </rewrite>


    In principle it works here as well, but e.g. the subfolders like old.dom1.com/example are redirected to dom2.com/example. But all requests, including those to subfolders, should be redirected to dom2.com, but not requests to the subfolder "exception".

    Thanks for your help.

    Sunday, July 12, 2020 8:21 AM

All replies

  • User-460007017 posted

    Hi lakul83,

    Please try this rule. It redirect old.dom1.com/* to dom2.com/* but it won't redirect old.dom1.com/exception

    <rule name="CanonicalHostNameRule" stopProcessing="true">
                        <match url=".*" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="old.dom1.com" />
                            <add input="{URL}" pattern="^/exception(.*)" negate="true" />
                        </conditions>
                        <action type="Redirect" url="https://dom2.com/{R:0}" />
                    </rule>

    Best Regards,
    Jokies Ding

    Monday, July 13, 2020 2:55 AM
  • User-2090838193 posted

    Thanks @Yuk Ding for clearing my ambiguities, 
    The best thing of this forum I have learnt all of things by just reading the threads.

    Thursday, April 29, 2021 1:26 PM