B
B
bossigorxxx2019-08-19 08:43:18
htaccess
bossigorxxx, 2019-08-19 08:43:18

Website redirect after switching from Yandex Zen?

The problem is that users access from the Yandex Zen feed at a URL like
https://site.ru/karty/sovet-tem-kto.html?utm_refer...
https://site.ru/karty/sovet-tem-kto.html ?utm_refer...
https://site.ru/znat/skolko-mogut-snimat.html?utm_...
It is necessary to redirect from these URLs to the normal short address of the pages:
https://site.ru/karty/sovet -tem-kto.html

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bossigorxxx, 2019-08-19
@bossigorxxx

Found the answer:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} utm_referrer=(.*)
RewriteRule ^(.*)$ /$1? [R=301,L]
</IfModule>

V
Viktor Taran, 2019-08-19
@shambler81

1. www.adventum.ru/blog/rel-canonical-how-to to help you and don’t invent a wheel
2. Prohibit indexing get parameters in robots, especially since they start with utm
3. sitemap.xml
4. GET parameter is not part of url and is allocated as a separate request in the rewrite cond, so you can make a condition for all
utm

RewriteCond %{QUERY_STRING} (^|&)utm_referrer\=https\://zen\.yandex\.com($|&)
RewriteRule ^karty/sovet\-tem\-kto\.html$ /? [L,R=301]

for all UTMs
RewriteCond %{QUERY_STRING} (^|&)utm_referrer\=.+($|&)
RewriteRule ^(.+)$ /$1/? [L,R=301]

? At the end of the line will remove the get parameters

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question