[spoiler]
AddEventHandler('main', 'OnEpilog', 'setCanonical', 1); function setCanonical() { global $APPLICATION; if (strpos($APPLICATION->GetCurPageParam(), '?') !== false) { if ($APPLICATION->GetPageProperty('canonical') == '') { CMain::IsHTTPS() ? $s = 's' : $s = ''; $canon_url = 'http' . $s . '://' . SITE_SERVER_NAME . $APPLICATION->GetCurPage(); $APPLICATION->AddHeadString('<link href="' . $canon_url . '" rel="canonical" />', true); //$APPLICATION->SetPageProperty("canonical", $canon_url); //если в админке задано canonical свойство, то можно им. } } } |