Answer the question
In order to leave comments, you need to log in
How to redirect to a subdomain?
Good afternoon. Let's say there is a page on the site site.ru/page/ . How to redirect to the subdomain sub.site.ru/page/ when opening this page . Those. the main address should change to a subdomain with the /page/ page. The page is displayed the same.
Answer the question
In order to leave comments, you need to log in
RewriteCond %{HTTP_HOST} ^(www\.|)(site\.ru) [NC]
# защита от цикла, проверяем нет ли доменов 3 уровня.
RewriteRule ^(.*)$ http://$1\.site.ru [R=301,L]
#перенаправляем все на домен 3
RewriteCond %{HTTP_HOST} ^(www\.|)(site\.ru) [NC]
# защита от цикла, проверяем нет ли доменов 3 уровня.
RewriteRule ^page/$ http://page\.site.ru [R=301,L]
#перенаправляем все на домен 3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question