Answer the question
In order to leave comments, you need to log in
How to remove duplicate pages in search engine results?
Guys, help me figure it out
. This is the situation, all categories of the site are listed without canonicals, which is why there are a huge number of duplicates.
How to catch the desired canonical value from the url (optional)?
There is the following url:
https://sayt.ru/catalog/1/page=2/
https://sayt.ru/catalog/1/order=named/page=2/
Required value:
<link href="https://sayt.ru/catalog/1/" rel="canonical">
Answer the question
In order to leave comments, you need to log in
It all depends on the technical part, the engine, the framework.
In the simplest case, the current URL without domain and protocol is in the variable $_SERVER['REQUEST_URI']
For https://sayt.ru/catalog/1/page=2/
$_SERVER['REQUEST_URI'] = '/catalog/1/page=2/ ';
For https://sayt.ru/catalog/1/order=named/page=2/
$_SERVER['REQUEST_URI'] = '/catalog/1/order=named/page=2/ ';
<?php
$rel_canonical = '';
if(preg_match('!^/catalog/([0-9]+)!si', $_SERVER['REQUEST_URI'], $out))
{
$rel_canonical = "https://sayt.ru/catalog/{$out[1]}/";
}
//$rel_canonical выводим на странице
1) put redirects (or 403/404 but better redirects)
2) write a canonical
3) remove them from the sitemap
wait (you can "ask" Yandex to speed up the removal)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question