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?
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
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?
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...
Thanks Daniel, I will look into this.
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!
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...