1

I am trying to redirect https://www.mydomain.com/en to my default site i.e. https://www.mydomain.com/en-US

I have tried with Sitecore module, it is working if i select any language other than en like en-In, en-AU but not with en.

I am trying with IIS redirection module with below rule

 <rule name="English Redirect" stopProcessing="true">
    <match url="^/en?$" />
    <action type="Redirect" url="http://www.mydomain.com/en-US" appendQueryString="false" />
  </rule>

is there anything wrong in the rule? or any limitation from sitecore that we can not redirect protected language?

1

Try the following rule:

<rule name="Default Language" patternSyntax="ExactMatch" stopProcessing="true">
    <match url="en" />
    <action type="Redirect" url="/en-us" />
</rule>

You don't need wildcard or regexes for matching exact url - just use ExactMatch pattern syntax - it will be microseconds faster, but remember that it's compared for every request.

Moreover, what is passed to the rule url condition, never starts with '/' character, so if your url is http://www.mydomain.com/en, only 'en` will be compared with url condition.

I tried it on my local Sitecore instance and it worked.

|improve this answer|||||
0

You need to omit the beginning / in your match, which is why Marek Musielak's answer works for him. He also changed the patternSyntax to ExactMatch, which would be equivalent to:

<rule name="English Redirect" stopProcessing="true">
  <match url="^en$" />
  <action type="Redirect" url="http://www.mydomain.com/en-US" appendQueryString="false" />
</rule>
|improve this answer|||||

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.