[Cialug] Rewrite rule help

Matthew Nuzum newz at bearfruit.org
Tue Aug 9 13:08:47 CDT 2011


I have this ugly rewrite rule that works to redirect mobile browsers to a
mobile page. I tried inverting the logic and making it redirect desktop
browsers to the non-mobile site. I thought it was working but as I moved to
a new server it is either no longer working or it never was.

This works and sends mobiles to the right place:
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_USER_AGENT} !ELB-HealthChecker [NC]
RewriteCond %{HTTP_ACCEPT} "text/vnd.wap.wml|application/vnd.wap.xhtml+xml"
[NC,OR]
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|erics|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]
RewriteRule ^(.*)$ http://mysite.com/ [L,R=302]

This isn't:
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_ACCEPT} !"text/vnd.wap.wml|application/vnd.wap.xhtml+xml"
[NC]
RewriteCond %{HTTP_USER_AGENT}
!"acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-"
[NC]
RewriteCond %{HTTP_USER_AGENT}
!"dang|doco|erics|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-"
[NC]
RewriteCond %{HTTP_USER_AGENT}
!"maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC]
RewriteCond %{HTTP_USER_AGENT}
!"palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany"
[NC]
RewriteCond %{HTTP_USER_AGENT}
!"sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo"
[NC]
RewriteCond %{HTTP_USER_AGENT}
!"teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC]
RewriteCond %{HTTP_USER_AGENT} !"wapp|wapr|webc|winw|winw|xda|xda-" [NC]
RewriteCond %{HTTP_USER_AGENT}
!"up.browser|up.link|windowssce|iemobile|mini|mmp" [NC]
RewriteCond %{HTTP_USER_AGENT}
!"symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
RewriteRule ^(.*)$ http://www.mysite.com/ [L,R=302]

Any idea what I'm missing?

-- 
Matthew Nuzum
newz2000 on freenode, skype, linkedin and twitter

♫ You're never fully dressed without a smile! ♫
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cialug.org/pipermail/cialug/attachments/20110809/3200a7dc/attachment.html>


More information about the Cialug mailing list