I need to 301 redirect from one domain to another and include the sub path E.g.:
https://old-domain.com/contact --> https://new-domain.com/contact
How is that possible.
For now I have the following that is not including the sub path
<rule name="Redirect" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" ignoreCase="false" />
<action type="Redirect" url="https://opoura.com/" />
</rule>
You are missing the path in the action
. You can include it like this:
<rule name="RedirectToNewDomain" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^old-domain\.com$" />
</conditions>
<action type="Redirect" url="https://opoura.com/{R:1}" redirectType="Permanent" />
</rule>
Source: Web.config redirects with rewrite rules - https, www, and more.