Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @{
- var canonicalUrl= String.Empty;
- if(umbraco.library.RequestServerVariables("HTTP_HOST").ToLower().StartsWith("www")) {
- canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables("HTTP_HOST"), CurrentPage.GetPropertyValue("umbracoUrlAlias"));
- } else {
- canonicalUrl = string.Concat("http://www.", umbraco.library.RequestServerVariables("HTTP_HOST"), CurrentPage.GetPropertyValue("umbracoUrlAlias"));
- }
- <link rel="canonical" href="@canonicalUrl" />
- }
- @using umbraco
- @using System
- @{ var canonicalUrl= String.Empty; }
- @if(umbraco.library.RequestServerVariables("HTTP_HOST").ToLower().StartsWith("www")) {
- canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
- } else {
- canonicalUrl = string.Concat("http://www.", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url); }
- <link rel="canonical" href="@canonicalUrl" />
- @using umbraco
- @using System
- @{var canonicalUrl= String.Empty;}
- @if(umbraco.library.RequestServerVariables ("HTTP_HOST").ToLower().StartsWith("www")) {
- canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
- } else {
- canonicalUrl = string.Concat("http://www.", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
- }
- <link rel="canonical" href="@canonicalUrl" />
- @using umbraco
- @using System
- @* empty out the string *@
- @{var canonicalUrl= String.Empty;}
- @* check if the requested URL starts with www. *@
- @if(umbraco.library.RequestServerVariables("HTTP_HOST").ToLower().StartsWith("www")) {
- @* adds http:// to the beginning *@
- canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables ("HTTP_HOST"), Model.Url);
- @* strips out the www. from the URL *@
- canonicalUrl = umbraco.library.Replace(canonicalUrl, "www.", "");
- } else {
- @* if they did not use the www prefix, we still have to add http:// to the URL *@
- canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
- }
- <!-- output the canonical URL -->
- <link rel="canonical" href="@canonicalUrl" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement