Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, February 19, 2015

Language suffix 'en' is being added into the URL of Sitecore website

Recently I come across with interesting requirement in Sitecore.

Whenever any new user tries to access any page of website first time, language suffix ‘en’ is adding into the URL. If same user tries to access the same page again then ‘en’ is not including into the URL. Let’s understand it with example.

When the user is on  and clicks to go to the any pages, the URL user is taken to is , which should be  and when user clicks LMN link, URL is , should be .

This is only occurring the first time the user visits the page. If the user clicks away from one of these pages to a different page and then clicks back to the previous page, the URL's no longer contain the 'en'.

How to fix this?

Open web.config file and locate languageLocation in linkManager section. Its different values are asNeeded, always and never. By default its asNeeded so language siffix added into the URL first time the user visits the page.
If you set Never, you will never get the language suffix in URL.

    <linkManager defaultProvider="sitecore">
        <add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="false" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="never" languageLocation="filePath" lowercaseUrls="true" shortenUrls="true" useDisplayName="false"/>

Please leave your comments or share this tip if it’s useful for you.

No comments:

Post a Comment