jeudi 30 avril 2015

Htaccess mobile redirect two subdomains

can anyone please help

I have a website www.example.com which redirects to www.m.example.com

This works perfectly with the following htaccess code

# Check if this is the m=no query string


RewriteCond %{QUERY_STRING} (^|&)m=no(&|$)
 # Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]
 # Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
 RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
    RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
    RewriteCond %{HTTP:Profile}       !^$
# Check if we're not already on the mobile site
 RewriteCond %{HTTP_HOST} !^m\.
 # Can not read and write cookie in same request, must duplicate condition
 RewriteCond %{QUERY_STRING} !(^|&)m=no(&|$) 
 # Check to make sure we haven't set the cookie before
 RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]
 # Now redirect to the mobile site
RewriteCond %{REQUEST_URI} !\.(?:gif|jpe?g|png)$ [NC] 
RewriteRule ^ http://m.example.com%{REQUEST_URI} [R,L]

However my problem is I also have the subdomain ru.example.com which is now being redirected to the mobile subdomain m.. I do not want this subdomain ru to be redirected to the mobile version.

I want the desktop site www.example.com to be redirected to www.m.example.com

I want the desktop site www.ru.example.com to be redirected to www.mob.example.com

Please help thanks

Aucun commentaire:

Enregistrer un commentaire