I want to eliminate the language token from the url


and rewrite it to


can someone explain whats wrong with this IIS rewrite rule?

<rule name="rewrite_languageparameter_en" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
  <match url="http://www.mydomain.de/en-us/*" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
  <action type="Redirect" url="www.mydomain.com/{R:1}" />

I have also tried this, but nothing happend:

<rule name="rewrite_languageparameter_en" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
                <match url=".mydomain.de/([_0-9a-z-]+)/([_0-9a-z-]+)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                <action type="Redirect" url="www.mydomain.com/{R:2}" />

Your regex isn't well formed. Your first example doesn't have a selector for R:1.

This works for any directory structure after the "en-us".

Edit for domain switch.

<rule name="Language redirect" stopProcessing="true">
<match url="^en-us/([a-z0-9-\./]*)" />
<action type="Redirect" url="http://www.mydomain.com/{R:1}" />
    <add input="{HTTP_HOST}" pattern="^www.mydomain.de$" />
| improve this answer | |
  • good explanation for generic elimination but how to redirect from mydomain.DE to mydomain.COM as i mentioned in my question? – Matt Feb 12 '14 at 12:00
  • Apologies. My brain didn't pick that up. Edit made. – Papa Feb 12 '14 at 23:07
  • thanks @Papa , i would give plus one, but i have not enough reputation. :) – Matt Feb 14 '14 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.