A
A
Anton Ivanov2022-03-01 16:35:22
Apache HTTP Server
Anton Ivanov, 2022-03-01 16:35:22

How to make a redirect from the internal page of any subdomain to the internal page of the main domain?

Hello everyone)

Please tell me how to implement this. There is a site on Bitrix and it has subdomains with regions
. And inside there is a section with articles. The bottom line is to prevent duplicate articles in search engines.
Here you need to make it so that when you visit an article from subdomains, it redirects to this article on the main domain Here is an example, you need to redirect to https ://site

from this page .ru/news/stati/statya1/ It seems to be not such a difficult task, but the code below does not work :( RewriteCond %{HTTP_HOST} ^(?>www\.|)(.+)\.site\.ru/news/ stati/(.+)$ [NC] RewriteRule ^(.*)$ https://site.ru/news/stati/%1/ [R=301,L]





Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2022-03-01
@Rsa97

Look carefully at your routine. The first parameter is not the title of the article, but the subdomain.

V
Viktor Taran, 2022-03-01
@shambler81

RewriteCond %{HTTP_HOST} ^(www\.|)sub1\.site\.ru$
RewriteRule ^(.+)$ https://site.ru/$1? [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question