In addition to @Anton answer,
Sometimes site resolving logic might seem to work in unexpected ways (for example, when opening items in the
Experience Editor or in the
Preview mode), but in fact, the behavior is affected by special configuration settings that can be changed according to your requirements.
It is recommended to keep the
Rendering.SiteResolving setting value at
true for any multisite solution in order to ensure that cross-site links are built with the correct parameters.
Experience Editor and Preview mode is opened in the context of the site defined in the
In my case, I observed the page preview mode was throwing an error, and when I looked into the
Preview.Default setting in
Sitecore.config file, it was pointing to
So, there are two options you can try here to resolve this issue:
- Update the “website” site node start item in
Sitecore.config to point to active site/ location or
- Update the
Preview.DefaultSite mode settings with an active site.
Please make any updates to Sitecore.config using Sitecore patch file, so that we don’t mess up anything with the default configurations, and down the line didn’t face any issue with Sitecore upgrade as well.
Also, to make sure that items are opened in context of correct site, we must set the
Rendering.SiteResolvingMatchCurrentSite setting to
All configs related to site resolving can be found (/App_Config/Sitecore.config)
Please read more about the site resolving here- https://kb.sitecore.net/articles/986056
Hope it helps!