B
B
busidoway2017-08-01 09:21:39
htaccess
busidoway, 2017-08-01 09:21:39

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

2 answer(s)
V
Viktor Taran, 2017-08-01
@shambler81

RewriteCond %{HTTP_HOST} ^(www\.|)(site\.ru) [NC]
# защита от цикла, проверяем нет ли доменов 3 уровня.
RewriteRule ^(.*)$ http://$1\.site.ru [R=301,L]
#перенаправляем все на домен 3

now if a specific word
RewriteCond %{HTTP_HOST} ^(www\.|)(site\.ru) [NC]
# защита от цикла, проверяем нет ли доменов 3 уровня.
RewriteRule ^page/$ http://page\.site.ru [R=301,L]
#перенаправляем все на домен 3

A
AlexFlip, 2017-08-01
@AlexFlip

You can simply redirect the user on this page via php
header('Location: http://sub.site.ru/page/');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question