We have a website with two languages - en & jp. When the URL mysite.com is browsed, it should load jp content. Just like browsing mysite.com/jp, but the URL should be mysite.com

The Site structure in CMS is like this

My Site

I used a patch config to overwrite SiteDefinition.config settings like this:


      <site name="MySite" patch:before="site[@name='website']"
            rootPath="/sitecore/content/Home/My Site"


      <patch:attribute name="defaultProvider">MySite</patch:attribute>
        <clear />
        <add name="MySite" 
             type="Sitecore.Links.LinkProvider, Sitecore.Kernel" 

This worked and when I browse mysite.com, It loads the Japanese content. However, this led to a new issue.

All the href in anchor tags work fine when viewing the site in jp, but in en they are incorrect.

e.g in jp it is

<a href="/jp/mypage"></a>

but in en it is

<a href="/en/My-Site/Home/mypage"></a>

Seems like, just changing the language atttribute in SiteDefinition.config won't be the solution.

Please advise, what should be done to fix this?

Using sc8.2u3

  • Try adding second site definition after MySite, call it MySiteEn and use same settings as for MySite just change language to en Jan 8 '18 at 9:50
  • @MarekMusielak I have two concerns here #1. Will jp be still the default site. #2 We have used the website name "MySite" in code. If MySiteEn is now added, I'm afraid where is it gonna break the site.
    – Qwerty
    Jan 8 '18 at 9:57
  • When a request arrives to your application, it tries to match the first site with settings from site definition. If request is for jp language, it matches MySite definition. If request is for en language, it doesn't match MySite and it uses website instead. That's why your en links are incorrect. If you used MySite in the code, maybe think about changing it to site.Name.StartsWith("MySite") or something like that. Jan 8 '18 at 10:01
  • I had similar requirements for a site, setting the default language to something else didn't do this behavior. So maybe something else is messing with it. How are you generating the URLs?
    – TamerM
    Jan 8 '18 at 10:04
  • @TamerM. No custom code. @Html.Sitecore().Field(<fieldID>, item). But I am using a custom config for LinkManager that I have updated in question.
    – Qwerty
    Jan 8 '18 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.