Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Until now, to get the canonical url in a page, i'd used this razor code:
<link rel="canonical" href="@Umbraco.NiceUrlWithDomain(CurrentPage.id)" />
But the problem is that this code creates an url on http... Not on https...
How can I solve it?
Hi Bob
Try to use this code:
string url = Request.Url.Authority + Request.RawUrl; if (Request.ServerVariables["HTTPS"] == "on") { url = "https://" + url; } else { url = "http://" + url; }
Thanks,
Alex
Hi Alex and thank you for your quick response.
Your code doesn't fit in my case 'cause if the page you request had an internal redirect it doesn't appear on the canonical tag...
Thank you the same!
Hi Bob,
check the web.config and search for umbracoUseSSL and set this to true.
<add key="umbracoUseSSL" value="true" />
Then it will be https!
Hope this helps!
/Michaël
I try your solution and it works on a domain. But on another domain it doesn't do the code changement to https. And another problem is that with this code on the web.config I can't access to umbraco backoffice.
Really strange...
you mean you have multiple domains in one Umbraco installation?
No, sorry, I have not explained well...
On a website this web.config change works. On another not, and I've the problem that I explain above.
Do both website use the same version of Umbraco? Which versions do they have and on which one it works and on which one it doens't work?
They both have the 7.2.7 Umbraco Version.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get canonical url with https on razor
Until now, to get the canonical url in a page, i'd used this razor code:
But the problem is that this code creates an url on http... Not on https...
How can I solve it?
Hi Bob
Try to use this code:
Thanks,
Alex
Hi Alex and thank you for your quick response.
Your code doesn't fit in my case 'cause if the page you request had an internal redirect it doesn't appear on the canonical tag...
Thank you the same!
Hi Bob,
check the web.config and search for umbracoUseSSL and set this to true.
Then it will be https!
Hope this helps!
/Michaël
I try your solution and it works on a domain. But on another domain it doesn't do the code changement to https. And another problem is that with this code on the web.config I can't access to umbraco backoffice.
Really strange...
Hi Bob,
you mean you have multiple domains in one Umbraco installation?
/Michaël
No, sorry, I have not explained well...
On a website this web.config change works. On another not, and I've the problem that I explain above.
Do both website use the same version of Umbraco? Which versions do they have and on which one it works and on which one it doens't work?
/Michaël
They both have the 7.2.7 Umbraco Version.
is working on a reply...