Skip to content

Instantly share code, notes, and snippets.

@bxtimur
Last active January 30, 2020 13:26
Show Gist options
  • Save bxtimur/90dd62fad283241e0923f9e5b6bd5b67 to your computer and use it in GitHub Desktop.
Save bxtimur/90dd62fad283241e0923f9e5b6bd5b67 to your computer and use it in GitHub Desktop.
// Canonical
$curpage = $APPLICATION->GetCurUri();
$arPagen = array('PAGEN_1', 'PAGEN_2');
foreach ($arPagen as $pageParam) {
if (strpos($curpage, $pageParam) !== false) {
$newpage = 'http';
$newpage .= $_SERVER["HTTPS"] ? 's' : '';
$newpage .= '://' . $_SERVER["SERVER_NAME"];
$newpage .= $APPLICATION->GetCurPage(false);
$APPLICATION->AddHeadString('<link rel="canonical" href="' . $newpage . '" />');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment