This project has moved and is read-only. For the latest updates, please go here.

Languages collision

May 21, 2013 at 8:18 PM
First of all i have to say - this is very powerfull module and thank you for it!

I spent on it some time. It works for me on all NBStore rules and tabs rules - that is great! But i got one issue when made some tests with languages. Below are steps to recreate an issue:

1) At the begin we have single language "English (United States)".
2) Add "German (Germany)" language to the list of languages. So we can see 2 rules for "Culture" RuleTypeString.
3) At this point urls "/en/Home.aspx" and "/de/Home.aspx" work fine.
4) Add "English (Australia)" or "German (Austria)" language. This makes new rules for "Culture" RuleTypeString with "en-us", "de-de", "en-au", "de-at" URls. And it makes old urls 404 error. So:
"/en/Home.aspx" does not work and works only like "/en-us/Home.aspx" and
"/de/Home.aspx" does not work and works only like "/de-de/Home.aspx".

Is it possible to keep "/en/Home.aspx" so we do not kill this url and every new just to make with extension like it should be "/en-au/Home.aspx" or something like this.

There are some screenshots:
May 21, 2013 at 11:40 PM
Edited May 21, 2013 at 11:43 PM
OpenUrlRewriter rewrites uls based on providers. This is also true for the languange part of the url.

The included provider automaticaly use full culture code (en-US) when more then 1 culture is active with the same language part.

If you want you can make a other provider by your self that do wath you want. It's very easy.
Then you have to tell openurlrewriter to use your provider in the web.config.

In the future openurlprovider will automaticaly create a redirect for old urls.
May 22, 2013 at 9:02 AM
Thank you, Sacha! I will try to make changes you have suggested.
May 22, 2013 at 9:52 AM
Edited May 22, 2013 at 9:52 AM
If cant find how to do it, i can help you by that.

For testing, there is a simple way :

1) Create a directory in app_code
2) define this directory in your web.config
 <add directoryName="mySubDir1"/>

3) create your provider class in the new directory

4) add the provider to web.config

<urlRule defaultProvider="tabUrlRuleProvider">
    <add name="languageUrlRuleProvider" type="YourNameSpace.YourUrlRuleProvider"/>
May 22, 2013 at 9:53 AM

I have checked source code of the module and found one line of the code, where this issue can be fixed very easy. This is UrlRewriteModule.cs line #363:

if (key.Key.ToLower().Equals(culturePart.ToLower()))

when i replace it with ".StartsWith" instead of ".Equals":

if (key.Key.ToLower().StartsWith(culturePart.ToLower()))

In this way it works very good. So for example:

1) We have 2 locales "en-us" and "de-de". So urls are "/en/Home.aspx" and "/de/Home.aspx".
2) We add 2 more locales "en-au" and "de-at", so now urls looks like:
3) And with these fix i posted above we have old links "/en/Home.aspx" and "/de/Home.aspx" working fine and no 404 error.

4) Here is only one issue i can see, when user passes to the url corrupted localization with single letter like "/d/Home.aspx" it will go to the /de/Home.aspx".

What do you think about it?

Sergey, forDNN Team
May 22, 2013 at 9:54 AM
sachatrauwaen wrote:
If cant find how to do it, i can help you by that.

For testing, there is a simple way :
Thank you Sacha! Will try this too.
May 22, 2013 at 10:23 AM

Tried your method too - it works fine with me. So can be used both ways: first i described above in the "UrlRewriteModule.cs line #363" or own urlRuleProvider.


Sergey, forDNN Team
May 22, 2013 at 3:48 PM
What i dont like in your method, is that there are 2 different urls that return the same content.
That's not good for SEO.

In your use case the best is /de/Home.aspx is redirected to /de-de/Home.aspx

or to leave /de/Home.aspx for de-De.

Its not yet implemeted, but in the future the culture provider can generate rewrite and redirects.
May 22, 2013 at 3:53 PM
Ok, agreed its not very good method, but at least client do not lose "/de/Home.aspx" and other pages, because 404 error. Its probably temporary fix or something like that.
May 22, 2013 at 5:25 PM
I agree you have to do somting for 404 error.

You can stay with /de/Home.aspx for de-DE by making a new Culture provider.

You can easy only use the full culturecode if the short language code is not already used.