Answer the question
In order to leave comments, you need to log in
How to correctly create an htaccess redirect for different subdomains and domains?
Good afternoon,
The server hosts domains that are processed by one htaccess (refer to one folder with the site).
Previously, these domains were assigned subdomains of the form
mobile.sudmonain1.site 1 .ru
mobile.sudmonain2.site 1 .ru
mobile.sudmonain1.site 2 .ru
RewriteCond %{HTTP_HOST} ^(www\.)?mobile\.(.+) [NC]
RewriteRule ^(.*)$ http://m.%1/$1 [R=301,L]
m.sudmonain1.site 1 .ru
m.sudmonain2.site 1 .ru
m.sudmonain1.site 2 .ru
Answer the question
In order to leave comments, you need to log in
RewriteCond %{HTTP_HOST} ^(www\.|)mobile\(.+) [NC]
# domain with or without www select two groups before mobile and after
RewriteRule ^(.*)$ http://%1m%2/ $1 [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question