Master language not requiring language URL segment routing

Vote:
 

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?

Thanks,
/Mårten

#148429
May 12, 2016 16:49
Vote:
 

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

#148432
Edited, May 12, 2016 17:53
Vote:
 

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?

Thanks,
Mårten

#148433
May 12, 2016 18:08
Vote:
 

There are settings in admin here

http://webhelp.episerver.com/latest/cms-admin/managing-websites.htm

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

#148434
Edited, May 12, 2016 18:12
Vote:
 

Thanks Daniel, I will look into this.

#148435
May 12, 2016 18:15
Vote:
 

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:
http://world.episerver.com/Forum/Developer-forum/EPiServer-7-CMS/Thread-Container/2013/4/Language-enabled-but-not-available-cant-click-Translate-button/

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!

#148455
Edited, May 13, 2016 10:01
Vote:
 

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...
.EnumerableOf<IRoutingRule>("lastRouteRules")
.Contains(onlyHandleUrlsNotFilteredByUser,
handleCustom301s,
handleDefaultLanguageRedirects, 
handleSimpleAdresses,
handleDeleted410Pages,
handleDeleted404Pages,
handleRegexUrl)

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

#148459
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.