0

I am trying to do a custom domain mapping where in i have to map custom.seconddomain.com that is the custom domain and my app is hosted at app.firstdomain.com.

So i have added a CNAME entry to domain provider for seconddomain.com. Then added an IIS entry for custom.seconddomain.com in my server that hosts app.firstdomain.com. I have added a Rewrite rule in this IIS entry for the app routes to be rewritten to app.firstdomain.com. Its all well and good till this point.

<rule name="Subdomain rewrite" stopProcessing="true">
    <match url=".*" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="^((http)?(s)?:\/\/)?custom.seconddomain.com\/(.*)" />
        </conditions>
        <action type="Rewrite" url="http://app.firstdomain.com/" appendQueryString="true" />
</rule>

But now since the assets and resources will only be available at app.firstdomain.com, its failing to load those assests on custom.seconddomain.com. So for that i added a rule on IIS Rewrite rule to redirect the assests request from custom.seconddomain.com to app.firstdomain.com, but not sure if its due to the precedence of the rules or something else. Both the rules can’t seem to operate together.

<rule name="Rule 1">
    <match url="^((http)?(s)?:\/\/)?custom.seconddomain.com\/assets\/(.*)" />
        <conditions>
            <add input="{HTTP_REFERER}" pattern="^$" negate="true" />
        </conditions>
        <action type="Rewrite" url="https://app.firstdomain.com/assets/{R:4}" />
</rule>

I am new to IIS so was trying to achieve this through image hotlinking as well, to try and achieeve the desired outcome. Can you please let me know what am i missing here or doing wrong?

Andy A.
  • 1,392
  • 5
  • 15
  • 28

0 Answers0