Using ARR and URL Rewrite on IIS 10 but keeping trailing information

60 Views Asked by At

Hopefully someone can help here as I am struggling with the Regex for the rule. I have ARR installed on IIS and can do a test redirect for say www.example.com/github --> github.com and that works fine.

What I need to achieve is the following:-

http(s)://subdomain.example.com/course/course1/contents/465e5aa

to redirect to

example.externaldomain.com/course/course1/contents/465e5aa

It has to preserve the trailing information after the .com for all requests which will be created on the external site.

I feel totally stumped by the Regex needed for this.

I am happy for the redirected name to appear in the browser bar if that is easier.

1

There are 1 best solutions below

0
mattdean66 On

OK so I did get this working using a slightly different approach, welcome any comments as to whether this is a good way or not.

I created a new site in IIS for subdomain.example.com, created a web.config with the following:-

<rule name="Subdomain redirection" stopProcessing="true" enabled="true">
    <match url="(.*)" ignoreCase="true" />
    <action type="Redirect" url="https://example.externalsite.com/{R:1}" redirectType="Permanent" />
</rule>

This got me round trying to get the Regex right for subdomain.example.com in the match url in the main site example.com in IIS. Bit of a cheat I guess :-)