Try our conversational search powered by Generative AI!

Master language not requiring language URL segment routing


Hello, this question has been asked before ( here ) but I can't seem to find a straight answer to it.

Is there a way to modify the routing behavior so that the master language doesn't require the language segment. I.e. if the master language is english: 

* http://sitehost/News/ (goes to english page, because News master language is english) 
* http://sitehost/en/News/ (301 to http://sitehost/News/) 
* http://sitehost/sv/Nyheter/ (page in swedish) 
* http://sitehost/Nyheter/ (404 cause swedish is not the master language) 
* http://sitehost/en/Nyheter/ (404 due to mismatch between language segment and page-url-segment) 

This worked fine in EPi 6 with WebForms, now I want it to work like this in an EPi 9 MVC site. Is it possible?


May 12, 2016 16:49

Most of those should be working out of the box from what I can see...anyone in particular you are having problems with?
Are you defining default language per host in admin?
The 301 will probably not work out of the box if I remember correctly. Don't think they have implemented that yet. SEO Manager does it out of the box as well as a few other redirect rules to avoid duplicate content issues

Edited, May 12, 2016 17:53

The first one, the default routing (without language segment) to master language does not work - it serves me a 404.

Could you elaborate on defining default language per host in admin?


May 12, 2016 18:08

There are settings in admin here

You need to specify the culture property for each host that will act as default language...set it to "en" in the example above and it should work as intended without 404...

Edited, May 12, 2016 18:12

Thanks Daniel, I will look into this.

May 12, 2016 18:15

I solved the most pressing matter (case #1) with your link and an Alloy sample site to dabble with. Also this piece of information came in quite handy:

301 redirects (case #2) does not seem to work out of the box, so I suppose I need to write a separate handler/router for those.

Thanks again Daniel!

Edited, May 13, 2016 10:01

Yup, you can add a custom route later in the pipeline to fix that last redirect (and others). I have the following rules for SEO manager in my custom route that runs last

x.For<IRoutingService>().Use<RoutingService>() //These are the rules that should be run after EPiServer failes to match a url, typically doing a custom 301 or similar...

handleDefaultLanguageRedirects is the one you are after :) That one is pretty easy. Strip language tag (if master language) and see if UrlResolver can resolve the new url. If it can, redirect with 301...

May 13, 2016 10:55
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.