Skip to content

Instantly share code, notes, and snippets.

@if0rest
Last active April 5, 2021 11:33
Show Gist options
  • Save if0rest/269ae0b5efe1431cea3663e589ba6ae9 to your computer and use it in GitHub Desktop.
Save if0rest/269ae0b5efe1431cea3663e589ba6ae9 to your computer and use it in GitHub Desktop.
<?php
$curPage = $APPLICATION->GetCurPage(true);
if (substr_count($curPage, "catalog")) {
//Разрешаем индексацию канонических разделов по URL шаблонам
$indexPatterns = array(
"catalog/ulysse",
// ...
"catalog/seiko");
for ($i = 0; $i < count($indexPatterns); $i++) {
if (substr_count($curPage, $indexPatterns[$i]))
$indexFollow = true;
}
//Закрываем индексацию по URL шаблонам
$noindexPatterns = ["filter"];
for ($i = 0; $i < count($noindexPatterns); $i++) {
if (substr_count($curPage, $noindexPatterns[$i]))
$indexFollow = false;
}
//Закрываем индексацию: все страницы с GET параметрами, кроме списков товаров
if (!empty($_GET) && empty($_GET['PAGEN_1']))
$indexFollow = false;
if (!$indexFollow)
echo "<meta name='robots' content='noindex, follow'>\n";
else
echo "<meta name='robots' content='index, follow'>\n";
}
else
{
//Закрываем индексацию: страницы списков с главной и персональный раздел
if (($curPage == "/index.php" && !empty($_GET)) || substr_count($curPage, "personal"))
echo "<meta name='robots' content='noindex, nofollow'>\n";
else
$APPLICATION->ShowMeta("robots", false, $bXhtmlStyle);
}
?>
--
Источник: https://dev.1c-bitrix.ru/community/forums/messages/forum6/topic89429/message452103/#message452103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment