Last active
March 16, 2022 12:46
-
-
Save aktaumag/36c45babde04c1b3565cb607c78b8a3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ws_uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2); | |
$ws_uri_protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; | |
$ws_uri_canonical = $ws_uri_protocol . $_SERVER['HTTP_HOST'] . $ws_uri_parts[0]; |
WebaSyst
В админке находим шаблон и в файле index.html добавляем перед стандартным выводом тега небольшую модификацию
{$trimmed_absolute_url = $wa->currentUrl(true, true)}
{if empty($canonical)}
{if $wa->get('page', 1) > 1}
{$canonical_http = $wa->currentUrl(true)}
{else}
{$canonical_http = $trimmed_absolute_url}
{/if}
{else}
{$canonical_http = $canonical}
{/if}
{if !empty($canonical_http)}
{$canonical = $canonical_http|regex_replace:'/^http:\/\//':'https://'}
{/if}
{if !empty($canonical)}
<link rel="canonical" href="{$canonical}"/>
{/if}
// Перенаправление на страницу без index.php
$ws_uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2);
if(substr($ws_uri_parts[0], -10) == '/index.php'){
header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently");
header("Location: ".$wscanonical);
exit();
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CMS Bitrix
Отличная статья с видео инструкцией по настройке основной категории и канонических адресов для товаров, находящихся сразу в нескольких категориях: https://dev.1c-bitrix.ru/learning/course/?COURSE_ID=34&LESSON_ID=7199
bitrix/templates/имя-шаблона/header.php
bitrix/templates/имя-шаблона/components/bitrix/system.pagenavigation/.default/template.php