SaaS CMS has officially launched! Learn more now.

Always show language segment in URL



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 I want them to be "redirected" (both will of course be the same version of the page) to What do I need to do to solve this?


Edited, Nov 27, 2018 13:36

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.

Nov 27, 2018 14:56

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.

Nov 27, 2018 15:56

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 ).

Edited, Nov 27, 2018 21:05

Great answer, thanks! Will look into this.

Nov 28, 2018 9:02

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

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.