I am trying to setup a domain redirect as part of a domain migration. My caveat is that the site I am redirecting from is in a subfolder of a wider domain. I also need to retain the rest of the path and query string.
I need to setup a redirect in web.config that achieves the following:
- https://www.domain1.com/mysite to https://www.domain2.com
- https://www.domain1.com/mysite/users to https://www.domain2.com/users
- https://www.domain1.com/mysite/api/getData?inputParam=45 to https://www.domain2.com/api/getData?inputParam=45
I've tried:
<httpRedirect enabled="true" destination="https://www.domain1.com$V$Q" httpResponseStatus="Temporary" exactDestination="true" />
but this doesn't remove the "mysite" subfolder. It redirects to https://www.domain2.com/mysite instead of https://www.domain2.com
I've also tried creating a rewrite rule but I cannot figure out a working input and regex.
TIA.