Codesnipp.it Social Code Sharing

BookOfZeus

Redirect iPhone or Android to a Mobile WebSite

by BookOfZeus on Aug 24, 2011

//javascript //iPhone Version: if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { window.location = "http://m.bookofzeus.com/"; } //Android Version: if(navigator.userAgent.match(/android/i)) { window.location = "http://m.bookofzeus.com/"; } //php // iPhone Version: if(strpos($_SERVER['HTTP_USER_AGENT'],'iPhone') !== FALSE || strpos($_SERVER['HTTP_USER_AGENT'],'iPod') !== FALSE) { header('Location: http://m.bookofzeus.com/'); exit(); } // Android Version: if(strpos($_SERVER['HTTP_USER_AGENT'],'Android') !== FALSE) { header('Location: http://m.bookofzeus.com/'); exit(); } //.htaccess RewriteEngine On RewriteCond %{HTTP_USER_AGENT} "iphone|ipod|android" [NC] RewriteCond %{HTTP_HOST} !^m.bookofzeus.com RewriteRule ^(.*)$ http://m.bookofzeus.com/ [L,R=302]

Can't see the comments? Please login first :)