We're developing a multi-language site on latest Episerver and we're currently struggling with how to restrict languages per host. Our situation is that we have one site but many hosts, one for each country.
For most countries there is a straight language mapping, e.g. site.de has culture = de, site.fr has culture = fr.
Some countries, e.g. Belgium and Switzerland have multiple languages. But it seems a host definition can only have one language.
1) How can we make a restriction so that site.de does not allow /fr to get french content?
2) How can we allow certain hosts to accept multiple languages? (And restricted to only those languages)
I will answer these the wrong way round, but hope it makes sense!
2) By default all hosts should serve all language branches, the language mapping simply allows you to display a language without using a URL segment. So if site.be mapped to the be-BE locale then any content accessed on the site.be domain would show the be-BE language version of the content. If you also wanted to show be-FR version of the content then this would be accessed on site.be/be-FR/
1) Which makes the answer to this question a little more tricky. As EPiServer treats all language versions of content the same then in theory all hosts can serve all language versions. So for example site.se/be-FR would actually serve the French Belgian content on the Swedish site. I guess this is an undesired behaviour that you want to avoid? If thats the case then the IIS URL Rewrite module can be used to ensure inappropriate langauge URL segments are not shown. I wrote a blog about how to achive this http://www.david-tec.com/2011/04/Using-IIS7s-URL-Rewrite-feature-to-enable-good-SEO-practice-in-EPiServer/. If you are going to add languages/domains reguarly then you could write some code to avoid needing to write many URL Rewrite rules.
Hope all of the above makes sense and/or answers your questions. Let me know if you need to discuss further!
David, thanks for your answer. I was afraid I would have to go down this route (!) - wishing that there was already built-in support in EPI to handle this scenario.
In your case you had one host and one language. We have 15 hosts and 17 languages... so it seems we need to add a rewrite rule to each and every host, to explicitly deny the languages that are not supported for that host/country - which basically is all available languages but one...
That's about a zillion of rules :-/
I think we're better off handling it through code, as you suggest. Prolly thru a custom HttpModule. But we need to store the mapping site->language(s) in some place where it can be fetched efficiently. Using Episerver's HostDefinitions only support 1:1 scenarios which excludes Belgium and Switzerland.
I should probably add that I don't want to redirect to the country site when accessing an "unavailable language", e.g. site.se/en should not redirect to site.uk - it should return a 404.
Reasoning: If I try to access English content on the Swedish site I would expect to get "Swedish content in English" (something like en-SV although that culture does not exist). Redirecting me to the UK site probably won't be relevant for me.
Hi Johan, agree that you'd have to create a lot of rules - but if they don't need to change you'd only need to set them up once then forget about them. That wouldn't create the 404's of course so there is some dev work there. If it was acceptable you could use sub-domains to map the mutli-lingual countries, e.g:
Everything you ask for is possible through custom coding too!
Whether you take the config or code route you take I personally I feel spec'ing out the exact requirements to agree with the client and hand over the devs will be the most important part of getting this right :). Of course if you end up with something re-usable I'd personally love to read a blog about it on EPiServer World too ;)!