I am working on requirement where we are setting up multiple websites hostnames in a SXA Website using various Language Versions.


After doing the above setup, the URLs doesn't load as expected. The default Sitecore Home page under content folder [Outside Tenant, that is the default website] is being displayed. If I remove the virtual folders, the websites work fine with appending language parameters, like

Am I doing something wrong while configuring virtual folders? Anyone please help.

To add bit more, I have only one SXA site in Sitecore CMS Tree. The items have Language Versions, en-US, en-CA, fr-CA, es-MX. The requirement is to map the URLs with respective Language Versions of the website.


  • Check this post -> stackoverflow.com/questions/49009555/… Jun 13, 2022 at 9:17
  • Hi @PeterProcházka, this post describes about conventional way of doing it in sitecore. However, in SXA, we do the same in Site Groupings. I am following the same and entering values as I would have given that in sites definition patch file. But this is not working. Shall I do something else via Site Groupings, or add a patch file instead. Jun 13, 2022 at 9:27

1 Answer 1


I also have gone through this kind of scenario, where we have some items called fr, ca, en like that. So when we add these as a virtual folder and hit the URL, the Sitecore pipelines assume it as a Language and treat this like it.

To confirm this, if you pass some phrase, that is not a language like ep or ez etc then it will work.

So to solve this we created Custom Language Resolver, where we added some logic by splitting the URL and then check if the phrase is not a language. And then resolved it.

The logic we used looks something like this.

namespace App.Foundation.LanguageResolver.Pipelines
using System;
using System.Linq;
using Sitecore;
using Sitecore.Data.Items;
using Sitecore.Globalization;
using Sitecore.Pipelines.HttpRequest;
using WCMS.Foundation.Common.Extensions;

public class CustomLanguageResolver : Sitecore.Pipelines.HttpRequest.LanguageResolver
    public override void Process(HttpRequestArgs args)
        if (Context.Site == null
           || Context.Site.Name == "shell"
           || Context.Site.Name == "service"
           || !Context.PageMode.IsNormal
           || string.IsNullOrEmpty(args.StartPath))

        var splitUrl = args.LocalPath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

        var requestedLanguage = splitUrl.NotEmpty() ? splitUrl.First() : string.Empty;

        if (requestedLanguage.Contains("healthz"))

        Context.Language = Language.Parse("en");
        if (this.CheckItemLanguage(this.GetItem(args.StartPath), requestedLanguage))
            Context.Language = Language.Parse(requestedLanguage);

    public bool CheckItemLanguage(Item item, string requestedLanguage)
        Sitecore.Collections.LanguageCollection collection = Sitecore.Data.Managers.ItemManager.GetContentLanguages(item);
        foreach (var lang in collection)
            var itm = Sitecore.Context.Database.GetItem(item.ID, lang);
            if (itm.Versions.Count > 0 && lang.Name.ToLower() == requestedLanguage.ToLower())
                return true;

        return false;
    public Item GetItem(string id)
        return Context.Database.GetItem(id);


And then added this in a patch file like this.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:environment="http://www.sitecore.net/xmlconfig/environment/">
        <setting name="Languages.AlwaysStripLanguage" value="false" />
       <processor type="Sitecore.Pipelines.HttpRequest.LanguageResolver, Sitecore.Kernel">
         <patch:attribute name="type">App.Foundation.LanguageResolver.Pipelines.CustomLanguageResolver, WCMS.Foundation.LanguageResolver</patch:attribute>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.