Answer the question
In order to leave comments, you need to log in
How to redirect correctly with htaccess?
How to record correctly so that when entering without www there is a redirect, such a record only if we enter the site from www works.
RewriteCond %{HTTP_HOST} ^www\.site\.ru [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://m.site.ru/$1 [L,R=302]
Answer the question
In order to leave comments, you need to log in
If you need both options (with www and without).
RewriteCond %{HTTP_HOST} ^(www\.)?site\.ru$ [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://m.site.ru/$1 [L,R=302]
RewriteCond %{HTTP_HOST} ^site\.ru$ [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://m.site.ru/$1 [L,R=302]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question