Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Edgar Rasquin 326 posts 925 karma points
    Sep 16, 2021 @ 10:48
    Edgar Rasquin
    0

    Hi there,

    I am trying to redirect calls to the Umbraco backend to a domain that is different to the page domain.

    The following functionality should take place:

    All requests to

    customerDomain.com/umbraco
    

    (containing /umbraco in the querystring) should be forwarded to this subdomain:

    customerDomain.serviceDomain.com/umbraco
    

    Ideally remaining the whole querystring ({R:1}).

    I have tried to solve this in the IIS rewrite module. The problem is, that the rules just don't work even though I tested them successfully in the IIS rewrite module:

    So far I have tested 2 rules:

                <rule name="CanonicalHostNameRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{QUERY_STRING}" pattern="/umbraco*" />
                        <add input="{HTTP_HOST}" pattern="customerDomain\.com" />
                    </conditions>
                    <action type="Redirect" url="http://customerDomain.serviceDomain.com/{R:1}" redirectType="Temporary" />
                </rule>
    

    .

               <rule name="code4itUmbraco" stopProcessing="true">
                    <match url="/umbraco/*" />
                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="customerDomain\.com" />
                    </conditions>
                    <action type="Redirect" url="https://customerDomain.serviceDomain.com/" redirectType="Temporary" />
                </rule>
    

    In general it would be interesting to know, whether Umbraco is interfearing or if the IIS is the first hit before Umbraco logic starts.

    Also, is it possible to solve this task only within Umbraco and without the use of the IIS URL rewrite module?

    Thanks a lot for any comments or hints

  • Lucas Michaelsen 32 posts 232 karma points
    Sep 16, 2021 @ 11:42
    Lucas Michaelsen
    100

    Hello Edgar,

    The IIS URL rewrite, configuration controls this application. So even before Umbraco knows there is a request on it way. IIS Url rewrite is trying what is configured to do.

    Your first rule example is so close to be working. Instad of

    <add input="{QUERY_STRING}" pattern="/umbraco*" />
    

    you need to changes it to PATH_INFO

    <add input="{PATH_INFO}" pattern="/umbraco*" />
    

    You can read more about the diffendt IIS Url rewrite variables here:

  • Edgar Rasquin 326 posts 925 karma points
    Sep 16, 2021 @ 12:29
    Edgar Rasquin
    0

    Hi Lucas,

    thank you so much. It is working absolutely fine!

    You saved my day... have a great one.

Please Sign in or register to post replies

Write your reply to:

Draft