Yannis
Yannis

Reputation: 6157

Domain Redirect from domain.com/pathA to domainA.com

I have an IIS web server that is setup to handle all requests to *.myapp.com. We also have clients that have setup a custom domain, e.g. custom.customer.com as a CNAME To customer.myapp.com

I have a requirement to handle the following:

The problem I have right now is that this can't be done on the DNS level (as it involves paths). Also, whatever the "redirect" is I want the client to see his custom domain at all times. Like he should never see internal-app.com or myapp.com.

Is this possible in any way?

Upvotes: 0

Views: 34

Answers (1)

Victor Leontyev
Victor Leontyev

Reputation: 8736

It is possible with reverse proxy.

1) You need to install URL Rewrite and ARR module for IIS

2) Enable ARR. On the Application Request Routing page, select Enable proxy

3) Create rewrite rule

    <rewrite>
        <rules>
           <rule name="rewrite custom.customer.com/patha" stopProcessing="true">
                <match url="patha" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{HTTP_HOST}" pattern="^custom.customer.com$" ignoreCase="true" />
                </conditions>
                <action type="Rewrite" url="http://a.internal-app.com/" />
            </rule>
           <rule name="rewrite custom.customer.com/pathB" stopProcessing="true">
                <match url="pathb" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{HTTP_HOST}" pattern="^custom.customer.com$" ignoreCase="true" />
                </conditions>
                <action type="Rewrite" url="http://b.internal-app.com/" />
            </rule>
        </rules>
    </rewrite>

P.S. You might have problem with your resources(images,styles,css,js). Because your html might contains absolute paths to resources

You can check this post, when author is creating outbound rule for fixing relative urls https://blogs.iis.net/carlosag/setting-up-a-reverse-proxy-using-iis-url-rewrite-and-arr

Upvotes: 1

Related Questions