Answer the question
In order to leave comments, you need to log in
What will be the command in .htaccess?
Dear experts.
In the logs I often see that they are trying to access the site's articles using "crooked" links, with various appendages, I want to fix this.
There is this line
RewriteRule ^(.+?)\.html(?!/amp/).+$ https://%{HTTP_HOST}/$1.html [L,R=301]
https://site.ru/material.html - ссылки на материалы такие
https://site.ru/material.html/amp/ - ссылки на AMP (используются для мобильной выдачи Google) материалы такие
https://site.ru/kategoriya/ - ссылки на категории (разделы) такие
https://site.ru/tag/imya_tega/ - ссылки на теги, выводятся статьи с указанными в них тегами
https://site.ru/manage-subs-comments.html?srp=xxxxx&srk=yyyyy - ссылки на управление подпиской для посетителей, оставивших комментарии
Answer the question
In order to leave comments, you need to log in
RewriteCond %{QUERY_STRING} !^$
RewriteCond %{QUERY_STRING} !(^|&)srp=
RewriteCond %{QUERY_STRING} !(^|&)srk=
RewriteRule ^(.+?)\.html$ https://%{HTTP_HOST}/$1.html? [L,R=301]
RewriteRule ^(.+?)\.html(?!/amp/).+$ https://%{HTTP_HOST}/$1.html? [L,R=301]
RewriteCond $2 ^(?!/amp/).+ [OR]
RewriteCond &%{QUERY_STRING} ^(?!.*&srp=)(?!.*&srk=)&.+
RewriteRule ^(.+?)\.html(.*)$ https://%{HTTP_HOST}/$1.html? [L,R=301]
RewriteRule ^(.+?)\.html(?!/amp/).+$ https://%{HTTP_HOST}/$1.html [L,R=301]
RewriteRule ^(.+?)\.html(?!/amp/).+$ https://%{HTTP_HOST}/$1.html? [L,R=301]
# 301 --- http://www.test.com/faq.html?faq=13&layout=bob => http://www.test2.com/faqs.html
RewriteCond %{HTTP_HOST} ^www\.test\.com$
RewriteCond %{QUERY_STRING} (^|&)faq\=13($|&)
RewriteCond %{QUERY_STRING} (^|&)layout\=bob($|&)
RewriteRule ^faq\.html$ http://www.test2.com/faqs.html? [L,R=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question