url-rewritingiis-8dnn9

URL Rewrite to correct site language not working properly


I've added the below rule on the webconfig on the DNN9 portal of one of our customers.

<rule name="base site to CZ">
  <match url="^(.*)$" />
  <conditions>
      <add input="{HTTP_HOST}" pattern="^(www\.)?mysite.cz$" />
  </conditions>
  <action type="Redirect" url="https://www.mysite.cz/cs-cz{R:1}" />
</rule>

This should work as follows: If the url "www.mysite.cz" is called, load "www.mysite.cz/cs-cz" and show the site in czech language.

Instead it keeps showing the site in english.

As CMS we are usign DNN9 where the base language has been wrongli set to english by the customer, and once it has been enabled this cannot be changed anymore.

Can someone provide some help?

Thankyou in advance.


Solution

  • If you want to use url rewrite to set the language, then I suggest you use HTTP Cookie header on the request is set based on the requested URL. For example, assume that you have a web application that serves localized web pages. The web application determines the language for the response based on the HTTP cookie in the request. here a doc about how to use URL Rewrite Module to set HTTP headers and IIS server variables for you as a reference: how to use URL Rewrite Module to set HTTP headers