Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. @{
  2. var canonicalUrl= String.Empty;
  3.  
  4. if(umbraco.library.RequestServerVariables("HTTP_HOST").ToLower().StartsWith("www")) {
  5. canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables("HTTP_HOST"), CurrentPage.GetPropertyValue("umbracoUrlAlias"));
  6. } else {
  7. canonicalUrl = string.Concat("http://www.", umbraco.library.RequestServerVariables("HTTP_HOST"), CurrentPage.GetPropertyValue("umbracoUrlAlias"));
  8. }
  9. <link rel="canonical" href="@canonicalUrl" />
  10. }
  11.  
  12. @using umbraco
  13. @using System
  14.  
  15. @{ var canonicalUrl= String.Empty; }
  16. @if(umbraco.library.RequestServerVariables("HTTP_HOST").ToLower().StartsWith("www")) {
  17. canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
  18. } else {
  19. canonicalUrl = string.Concat("http://www.", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url); }
  20. <link rel="canonical" href="@canonicalUrl" />
  21.  
  22. @using umbraco
  23. @using System
  24. @{var canonicalUrl= String.Empty;}
  25. @if(umbraco.library.RequestServerVariables ("HTTP_HOST").ToLower().StartsWith("www")) {
  26. canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
  27. } else {
  28. canonicalUrl = string.Concat("http://www.", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
  29. }
  30. <link rel="canonical" href="@canonicalUrl" />
  31.  
  32. @using umbraco
  33. @using System
  34. @* empty out the string *@
  35. @{var canonicalUrl= String.Empty;}
  36. @* check if the requested URL starts with www. *@
  37. @if(umbraco.library.RequestServerVariables("HTTP_HOST").ToLower().StartsWith("www")) {
  38. @* adds http:// to the beginning *@
  39. canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables ("HTTP_HOST"), Model.Url);
  40. @* strips out the www. from the URL *@
  41. canonicalUrl = umbraco.library.Replace(canonicalUrl, "www.", "");
  42. } else {
  43. @* if they did not use the www prefix, we still have to add http:// to the URL *@
  44. canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
  45. }
  46. <!-- output the canonical URL -->
  47. <link rel="canonical" href="@canonicalUrl" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement