We have a server with multiple individual websites:
domain.com/masterSite
domain.com/site1
domain.com/site2
domain.com/siteN
We're in the process of migrating the multiple individual websites to a multi-tenant application (/mastersite). We are not doing this all at once; rather, we're migrating individual sites (200+) one at a time. And when a site is migrated to the multi-tenant site, we need a forwarding rule.
Example:
domain.com/site1 --> domain.com/masterSite/site1
domain.com/siteN --> domain.com/masterSite/siteN
The site names are all random, so we're going to use a Rewrite Map.
The issue is that I'm having trouble figuring out the pattern matching when using a rewrite map so that all requests to the path are forwarded regardless of extra URL data.
Here is current state:
<rewrite>
<rewriteMaps>
<rewriteMap name="ForwardToMTDB" defaultValue="">
<add key="/site1" value="/masterSite/site1" />
<add key="/site2" value="/masterSite/site2" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Rewrite Rule" enabled="true" stopProcessing="true">
<match url="(.+)" />
<conditions>
<add input="{ForwardToMTDB:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" logRewrittenUrl="true" redirectType="Found" />
</rule>
</rules>
</rewrite>
Examples of requests that should ALL go to domain.com/masterSite/siteN
domain.com/SiteN
domain.com/siteN/
domain.com/siteN/foo/bar
domain.com/siteN/somePage.aspx
domain.com/siteN/blah1/blah2/blah3/blah4/etc