November Happy Hour will be moved to Thursday December 5th.

Always show language segment in URL

Vote:
 

Hello!

I have a website with 4 different languages. On the master language, Swedish, I want to always show the /sv/ part of the URL. If the visitor goes to mypage.com/news I want them to be "redirected" (both will of course be the same version of the page) to mypage.com/sv/news. What do I need to do to solve this?

Thanks!

#199427
Edited, Nov 27, 2018 13:36
Vote:
 

Hi Emil,

For the first part (adding the /sv to all paths) you should be able to do that by removing the "culture" value from the host names defined for your site. By doing that, paths which don't have a locale at the start will return a 404 not found response. For the redirect, it's down to you how you implement it. You could probably use rewrite rules in your web.config to look for URLs which don't start with a locale though remember to exclude things like /episerver (or whatever you've set as your CMS UI path) and any non-episerver URLs such as static assets.

#199428
Nov 27, 2018 14:56
Vote:
 

Thank you for the answer! If I understand you correctly I should remove the value for Culture under Admin -> Config -> Manage Websites? Doesn't seem to change anything for me.

#199432
Nov 27, 2018 15:56
Vote:
 

Hi Emil,

You understod Pauls instruction correctly.

You could install Alloy MVC sample, it has english and swedish languages enabled. There is no culture specified for the site hosts in admin.

Now when you start the site and navigate to http://localhost:SOME-PORT-HERE/ you get the english version of start page. If you click any of the top navi links you notice that the path contains the language identifier like so: /en/alloy-plan/ (and the swedish pages use /sv/ in the url, I think you need to create and publish the swedish language version of start page in the Alloy demo).

Edit: one thing that comes to my mind is that if this is an older site or you have changed the 'strictLanguageRouting' setting then it might behave differently (see this old blog post ).

#199436
Edited, Nov 27, 2018 21:05
Vote:
 

Great answer, thanks! Will look into this.

#199463
Nov 28, 2018 9:02
Vote:
 

strictLanguageRouting was set to false. Thank you for the help!

#199464
Nov 28, 2018 9:07
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.