N
N
noxmag2019-02-27 09:38:46
htaccess
noxmag, 2019-02-27 09:38:46

How to make a redirect from the page of the main site site.ru/example to the subdomain example.site.ru?

How to make a redirect from the page of the main site site.ru/example to the subdomain example.site.ru?
1. Created a subdomain example.site.ru, attached to the existing one.
in .htaccess at the root of the main site I wrote:

RewriteEngine On
RewriteBase / 
#адрес поддомена
RewriteCond %{HTTP_HOST} ^(www\.)?example\.site\.ru$ [NC]
#папка на которую будет происходить переадресация
RewriteCond %{REQUEST_URI} !^/example/
#сама переадресация
#RewriteRule ^(.*)$ example/$1 [R=301, L]

2. Created an example folder in the root
3. Now the new site is opened at the addresses:
example.site.ru
site.ru/example

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
noxmag, 2019-02-28
@noxmag

Found the answer.

RewriteCond %{THE_REQUEST} "^[A-Z]+ /example" [NC]
RewriteRule doma/(.*)$ http://example.site.ru/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question