I am trying to implement a set of redirect rules for a number of URLs within a domain to specific URLs on another domain.
I've created the following redirect rules as an example:
<rule name="Redirect for Domain1" stopProcessing="true"><match url="^$"/><conditions trackAllCaptures="false"><add input="{HTTP_HOST}" pattern="^www.domain1.com$"/></conditions><action type="Redirect" url="http://www.domain2.com" redirectType="Permanent"/></rule><rule name="Redirect Domain1 URL 1" stopProcessing="true"><match url="section1"/><conditions trackAllCaptures="false"><add input="{HTTP_HOST}" pattern="^www.domain1.com$"/></conditions><action type="Redirect" url="http://www.domain2.com/section1/" redirectType="Permanent"/></rule><rule name="Redirect Domain1 URL 2" stopProcessing="true"><match url="section2"/><conditions trackAllCaptures="false"><add input="{HTTP_HOST}" pattern="^www.domain1.com$"/></conditions><action type="Redirect" url="http://www.domain2.com/section2/" redirectType="Permanent"/></rule>
I've tried using the following for the domain root to capture all URLs:
<rule name="Redirect for Domain1" stopProcessing="true"><match url=".*"/><conditions trackAllCaptures="false"><add input="{HTTP_HOST}" pattern="^www.domain1.com$"/></conditions><action type="Redirect" url="http://www.domain2.com" redirectType="Permanent"/></rule>
However this then prevents the redirection of individual URLs within the domain.
I've thought of monitoring any 404 errors in the log file and just adding the redirects to the list but obviously that does become hard to maintain.
Am I missing an obvious way of creating a catch-all that redirects everything as a blanket rule but also allows exceptions to exist to specific URLs on the new domain.
Sorry if this is a basic question but I've been struggling on this one for a while now.
Any help would be gratefully received.
Thanks
PS - The reason for the condition on the rules are because I'll be redirected a number of different domains on the same web.config file, so the rules need to be applied per domain.