B
B
Bronaz7772020-02-20 22:30:57
Search Engine Optimization
Bronaz777, 2020-02-20 22:30:57

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">


I read various forums and articles on Habré, but I did not find a solution to this particular problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nokimaro, 2020-02-20
@Bronaz777

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/ ';

That is, your problem can be solved as follows: if we see the /catalog/ID/ scheme in the url, then based on this we form the correct canonical url.
You can do this with a regular expression, for example.
It is assumed that in $rel_canonical we get the correct url that you then display on the page.
<?php
$rel_canonical = '';
if(preg_match('!^/catalog/([0-9]+)!si', $_SERVER['REQUEST_URI'], $out))
{
    $rel_canonical = "https://sayt.ru/catalog/{$out[1]}/";
}

//$rel_canonical выводим на странице

A
Antonio Solo, 2020-02-20
@solotony

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 question

Ask a Question

731 491 924 answers to any question