Answer the question
In order to leave comments, you need to log in
Automatic redirect of any subdomain to the domain name folder
Good afternoon,
to redirect a subdomain to a site folder, the name of which also matches the subdomain name, I use:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain\.mysite\.ru$
RewriteCond %{REQUEST_URI} !/subdomain/
RewriteRule ^(.*)$ /subdomain/$1 [L]
Answer the question
In order to leave comments, you need to log in
Working option:
RewriteEngine On
RewriteRule ^([a-zA-Z]+)/ - [L]
RewriteCond %{HTTP_HOST} ^(.*)\.mysite\.ru$
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R,L]
RewriteCond %{HTTP_HOST} ^(.*)\.mysite\.ru$
RewriteRule (.*) %1/$1 [L,QSA]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.mysite.ru$
RewriteCond %{HTTP_HOST} ^((.*)\.)mysite.ru$
RewriteRule ^/(.*) /%2/$1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question