Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Getting a language specific URL for a page?


I have a problem getting the language specific URLs for pages in EPiServer.

The background: I have developed a site with several enabled languages. EPiServerFramework.config is set up so that www.[client].se maps to the Swedish versions of the pages, www.[client].com to English, www.[client].es to Spanish, etc.

This works very well, and the pages doesn't have the /language/ URL prefix.

On the pages there is a possibility to click on links on the page to change to other language versions of the page (generated server-side).

My problem is - is there an easy way to generate these links, and automatically get them to point to the corrent domain name?

Right now I'm building the links with UriSupport.AddLanguageSelection(...), but that results in links such as /sv/blabla/ and /en/yadayada/, i.e. not including the domain, and each URL is prefixed with the language code.

While I realize it's easy to loop through EPiServerFrameworkSection.Instance.SiteHostMapping and do everything manually, I'd really like a more elegant (and automated) solution to this.

Does anyone have any experience of doing this?



Nov 08, 2010 16:53
 UrlBuilder url = new UrlBuilder(EPiServer.Configuration.Settings.Instance.SiteUrl + linkUrl);
EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, page.PageLink, UTF8Encoding.UTF8);


Will give the right url, but you need to provide the SiteUrl

Nov 08, 2010 19:40

Good idea, although it still includes the language URL prefix.

I ended up writing my own utility method for building the corresponding URL.

Nov 09, 2010 15:36
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.