Erica Stockwell-Alpert
Erica Stockwell-Alpert

Reputation: 4863

Sitecore multisite - links on Site A to Site B are resolving as paths under site A rather than going to the Site B domain (C#)

Sorry if the title is confusing, but basically I have a primary site, Site A (sitecore/content/Home), and a microsite, Site B (sitecore/content/SiteBHome). On a few pages, I'm inserting Sitecore links to Site B. However, these resolve as /SiteBHome/page and take me to siteA.com/sitebhome/page rather than siteB.com/page

How do I fix this? I had a redirect for siteA.com/sitebhome -> siteB.com, but this loses the path and just sends me to the home page, so I've removed it for now:

<rule name="homepage path Redirect" stopProcessing="true">
  <match url="^second-site-home/?(.*)$" />
  <action type="Redirect" url="http://secondsite.org" redirectType="Found"/>
  <conditions>
    <add input="{HTTP_HOST}" pattern="^(www\.)?mysite.com$" />
  </conditions>
</rule>

I have a custom link provider class which currently looks like this, but I'm not sure how/if I can modify it to fix my links:

using Sitecore.Links;

namespace MySite.Library.CustomSitecore.Pipeline
{
    public class CustomLinkProvider : LinkProvider
    {
        public override UrlOptions GetDefaultUrlOptions()
        {
            UrlOptions urlOptions = base.GetDefaultUrlOptions();
            urlOptions.SiteResolving = true;
            return urlOptions;
        }
    }
}

Upvotes: 0

Views: 231

Answers (1)

Erica Stockwell-Alpert
Erica Stockwell-Alpert

Reputation: 4863

Turns out this was because I added a second domain to SiteB's site definition: hostName="siteB.com|Bsite.com. Sitecore is able to figure out pipes in the hostName value but when it comes to resolving site domains for links, the pipe messes it up. I fixed this by adding the targetHostName property, and now the links resolve correctly

Upvotes: 0

Related Questions