Reputation: 387
I need to write rewrite rules in IIS that will redirect to https://example.com/xml.
So
case 1: https://example.com/test
case 2: https://example.com/[country-lang-token]/test
(e.g https://example.com/en-us/test and https://example.com/fr-fr/test)
should be redirect to https://example.com/xml.
I know how to write rewrite rules but stuck due to regular expression.
Upvotes: 0
Views: 28
Reputation: 8736
Your rule should be like this:
<rule name="Redirect to xml" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_URI}" pattern="^/test$" />
<add input="{REQUEST_URI}" pattern="^/\w{2}-\w{2}/test$" />
</conditions>
<action type="Redirect" url="/xml" />
</rule>
First condition is for case 1 url https://example.com/test
Second condition is for case 2 https://example.com/[country-lang-token]/test
where [country-lang-token]
is string in format {two_letters}-{two_letters}
Upvotes: 1