add www prefix on canonical Link

rex extreme asked on July 17, 2020 01:08

Hi guys,

How do I add www prefix on canonical url? When i use the tree node absoluteUrl it doesn't have a www prefix (https://mydomain.com) even when the actual page url is https://wwww.mydomain.com. Is there a way to force it? Thanks in advance!

Recent Answers


Dmitry Bastron answered on July 17, 2020 11:12

Hi Rex,

Could you please provide a bit more information?

  • What version are you using?
  • Is it Portal Engine or MVC?
  • How do you embed the canonical URL? Could you paste this code, please?
0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on July 17, 2020 11:15

Is your domain itself in the sites application in Kentico configured to include www or did you enforce that using either settings or for example some rewrite rule

0 votesVote for this answer Mark as a Correct answer

Chidozie Bright answered on August 15, 2020 01:35

I would like to add to this question. I've ran into the issue in K11 of my canonical tag also not showing the www prefix. My original solution was to just update the site domain name in the Sites Application, however, that then triggered a licensing warning, since the license was registered without the prefix.

I am implementing the canonical as so in the masterpage: <link rel="canonical" href="{%CurrentDocument.AbsoluteURL.Replace("/en-us/", "/") #%}" />

This spits out https://domain.com/pagename but I need it to say https://www.domain.com/pagename

0 votesVote for this answer Mark as a Correct answer

rex extreme answered on August 18, 2020 00:50

I've resolved this by using the presentation URL. thanks for all your responses.

var canonicalURL = RequestContext.CurrentScheme + "://" + CMS.SiteProvider.SiteContext.CurrentSite.SitePresentationURL + RequestContext.CurrentURL;
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.