Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jesse Andrews 191 posts 716 karma points c-trib
    Jan 10, 2024 @ 00:07
    Jesse Andrews
    0

    Load balanced site with multiple domains and cultures sets wrong domain for canonical url

    I'm running into a strange issue where the wrong domain is sometimes set in the rel canonical tag. I'm pretty sure the problem is that Document.ContextInfo.Host is not returning the expected domain for some reason. When I call Model.Url(Culture, UrlMode.Absolute), the correct url is returned, so this appears to be an seo checker issue.

    Fortunately, it's not difficult to work around with a find and replace, but ideally I wouldn't have to take that step. I also updated the package to 2.11.5, but I'm not sure that will help as the changes in it aren't mentioned on the release notes page.

    For anyone else's reference, I'm doing the following

    var metaData = Model.Value<SEOChecker.MVC.MetaData>("seoChecker")
    var tags = metaData.AllTags.ToString();
    //hack to fix rel canonical tag
    var canonicalCheck = new Regex("<link rel=\\\"canonical\" href=\"([^\"]+)\"");
    var canonicalMatch = canonicalCheck.Match(tags);
    if (canonicalMatch != null) {
        var url = canonicalMatch.Groups[1].Value;
        tags.Replace(url, Model.Url(Culture, UrlMode.Absolute));
    }
    @Html.Raw(tags)
    

    SEO Checker: 2.11.4

    Umbraco: 8.18.9

  • Andreas Kristensen 71 posts 285 karma points c-trib
    Feb 20, 2024 @ 08:08
    Andreas Kristensen
    0

    I believe I am seeing a similar problem on SEO Checker version 12.0.1 on Umbraco 12.3.7.

    I will get the right URL from Umbraco when I call the URL() method. But the canonical from SEO Checker will just be the base address. But only on some pages.

Please Sign in or register to post replies

Write your reply to:

Draft