Multilingual Site: Set default alias path to specific culture

Tobias Beckendorff asked on March 3, 2021 17:23

Hi everyone.

I have a k12 portal engine site, e.g. https://domain.com.

The site has several cultures and I use the language prefix settings enabled, with 2 character Cultur Alias defined, so Homepage would be like

  • https://domain.com/en
  • https://domain.com/de
  • ...

Now I want the main url https://domain.com (without language prefix in url) to display the english version of the home page. When "Allow URLs without language prefixes:" is disabled, redirect to https://domain.com/en (or other culture because of cookies, browser-language) is happening. When option is enabled, the displayed language version still varies (again by cookies, browser-language).

Help apprectiated.

Recent Answers


David te Kloese answered on March 4, 2021 10:31

Have you set any culture settings?

The site config in the Sites module?

  • Default content culture:
  • Visitor culture:

Or global/site specific settings in the Settings module?

Content > Multilingual

  • Default content culture:
  • Combine with default culture:
0 votesVote for this answer Mark as a Correct answer

Tobias Beckendorff answered on March 4, 2021 12:12

Hi David,

Sites:

  • Default content culture: English
  • Visitor culture: (Automatic)

Settings:

  • Default content culture: English
  • Combine with default culture: false

Actually setting visitor culture to English culture forces English content on a fresh browser, which is good.

Still whenever CMSPreferredCulture cookie is present and set to a different culture, that cultures content is displayed. Is there a way to have Kentico ignore the cookie?

0 votesVote for this answer Mark as a Correct answer

Tobias Beckendorff answered on March 4, 2021 14:11 (last edited on March 4, 2021 14:14)

For now my solution is IIS Rewrite rule:

<rule name="homepage rewrite to english" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="^/?$" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
    <action type="Rewrite" url="/en" />
</rule>
0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on March 4, 2021 15:23

Ah you don't want a non-english version for just one page to show up? But how would a user get to the translation? When the CMSPreferredCulture cookie is set basically the user has a 'preference' or just visited that one last.

If you just don't have any other language for specifically the homepage you could just don't create it in other languages (or delete it). Together with the "combine with default culture" it would always render the default english (if that's the default culture).

0 votesVote for this answer Mark as a Correct answer

Tobias Beckendorff answered on March 5, 2021 08:26

Hi David,

thank you but that is not the case.

preconditions:

  • 1 Page (Homepage, set as default alias path)
  • different culture versions of the page
  • language prefix enabled in settings

requirement:

  • domain.com -> english (no matter what)
  • domain.com/en -> english
  • domain.com/de -> german

IIS Rewrite Rule is the way to go I guess.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on March 5, 2021 10:54

The only thing I can think of that might work without rewrite rules is using the home page settings:

Settings > Content -> Default alias path

Set this value to "/en" (type don't select)

Settings > URLs and SEO -> Default page

Set this drop down to "Use page defined by default alias path"

Keep in mind this does a permanent 301 redirect.

See more info in the docs at docs.xperience.io/k12sp/.../settings-urls-and-seo

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.