code_junkie

Standard way to detect mobile browsers in a web application based on the http request

Nov 11th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <VirtualHost (your-address-binding)>
  2.  
  3. (your-virtual-host-configuration)
  4.  
  5. RewriteEngine On
  6. RewriteCond %{QUERY_STRING} !ui=pc
  7. RewriteCond %{HTTP_COOKIE} !ui=pc
  8. RewriteCond %{HTTP_USER_AGENT} "^.*(iphone|ipod|ipad|android|symbian|nokia|blackberry| rim |opera mini|opera mobi|windows ce|windows phone|up.browser|netfront|palm-|palm os|pre/|palmsource|avantogo|webos|hiptop|iris|kddi|kindle|lg-|lge|mot-|motorola|nintendo ds|nitro|playstation portable|samsung|sanyo|sprint|sonyericsson|symbian).*$" [NC,OR]
  9.  
  10. RewriteCond %{HTTP_USER_AGENT} "^(alcatel|audiovox|bird|coral|cricket|docomo|edl|huawei|htc|gt-|lava|lct|lg|lynx|mobile|lenovo|maui|micromax|mot|myphone|nec|nexian|nook|pantech|pg|polaris|ppc|sch|sec|spice|tianyu|ustarcom|utstarcom|videocon|vodafone|winwap|zte).*$" [NC]
  11.  
  12. RewriteRule /(.*) http://bemoko.com/$1 [L]
  13.  
  14. RewriteCond %{QUERY_STRING} "ui=pc"
  15. RewriteRule ^/ - [CO=ui:pc:(your-cookie-domain):86400:/]
  16. RewriteCond %{QUERY_STRING} "ui=default"
  17. RewriteRule ^/ - [CO=ui:default:(your-cookie-domain):86400:/]
  18. </VirtualHost>
Add Comment
Please, Sign In to add comment