Hi @Ali Yılmaz,
For your needs, I think it would be feasible to create a rewrite map that defines a static mapping between the source URL and the redirect URL.
<rewriteMaps>
<rewriteMap name="Redirects">
<add key="/oldsite" value="/de-DE/p/newproduct" />
</rewriteMap>
</rewriteMaps>
Here you need to add a rewrite map according to your actual situation. For which old URLs you need to redirect to new URLs, add the corresponding keys and values.
Notice that there is no obvious common pattern in the keys and their relation to values. This means that it is not possible to use regular expressions or wildcards to define URL transformation logic. Further, this means that if we had not used rewrite maps we would have had to create three rewrite rules. With rewrite maps we can create only one rewrite rule.
The next step is to create a rule that uses "Redirects" rewrite map:
<rules>
<rule name="Redirect Rule" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="https://www.newsite.com{C:1}" appendQueryString="False" redirectType="Permanent" />
</rule>
</rules>
<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)">
To perform this check the value of the server variable REQUEST_URI is passed as a parameter to the rewrite map. If rewrite map contains an entry with key, that is the same as REQUEST_URI, then the value corresponding to that key will be returned. The regular expression pattern will match only non-empty strings, so if empty string was returned from the map then the condition will evaluate to false, hence no rewriting will be performed. If non-empty string was returned then that string will be captured in a back-reference, because of the parenthesis used in the pattern.
<action type="Redirect" url="http://localhost{C:1}" appendQueryString="False" redirectType="Permanent" />
This element specifies that URL rewrite module needs to redirect web client to a new URL that is constructed by concatenating the new domain name and the redirection URL path returned by "Redirects" map.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.
Best regards,
Yurong Dai