Forum Moderators: phranque
#Mobile detection
RewriteCond %{QUERY_STRING} !(.*&)?nomobile [NC]
RewriteCond %{REQUEST_URI} !\.*(jpg|png|css|this|that|otherthing)$ [NC]
RewriteCond %{HTTP_COOKIE} !^.*nomobile.*$ [NC]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
RewriteCond %{HTTP_USER_AGENT} !macintosh [NC] #*SEE NOTE BELOW
RewriteRule ^(.*)$ http://mobile.example.com [L,R=302]
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://www.example.com/mobile/ipad/ [R=301]
Looking at the rest of the Conditions, several are mutually exclusive or redundant. In particular,
RewriteCond %{REQUEST_URI} !\.*(jpg|png|css|this|that|otherthing)$ [NC]
RewriteCond %{REQUEST_URI} ^/$
say "Redirect if this is NOT a request for an image or css, in fact redirect ONLY when root / is requested".
So, which is it: "not images and css" or "only root"?
since this would override just about any image request below the root, correct?
I am not entirely sure - I didn't write the original code
Never mind what the code says. The question is: what do you want it to say?
RewriteEngine on
RewriteCond %{QUERY_STRING} !(.*&)?noipad [NC]
RewriteCond %{HTTP_COOKIE} !^.*noipad.*$ [NC]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_USER_AGENT} ipad [NC]
RewriteCond %{HTTP_HOST} !^example.com\. [NC]
RewriteRule ^ http://www.example.com/mobile/ipad/ [L,R=301]
RewriteEngine on
RewriteCond %{QUERY_STRING} !(.*&)?nomobile [NC]
RewriteCond %{HTTP_COOKIE} !^.*nomobile.*$ [NC]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_USER_AGENT} (iphone|android) [NC]
RewriteCond %{HTTP_HOST} !^example.com\. [NC]
RewriteRule ^ http://[mobile.example.com/ [L,R=301] [edited by: incrediBILL at 3:41 am (utc) on Mar 2, 2013]
[edit reason] disabled smilies [/edit]