引用:http://www.oschina.net/code/snippet_163910_6094
[代码] JavaScript判断方法
1 |
if (navigator.userAgent.match(/Android/i)) { |
2 |
// Do something! |
3 |
// Redirect to Android-site? |
4 |
window.location = 'http://android.davidwalsh.name' ; |
5 |
} |
[代码] PHP判断方法
1 |
if ( strstr ( $_SERVER [ 'HTTP_USER_AGENT' ], 'Android' )) { |
2 |
header( 'Location: http://android.davidwalsh.name' ); |
3 |
exit (); |
4 |
} |
[代码] 可以通过.htaccess来判断
1 |
RewriteCond %{HTTP_USER_AGENT} ^.*Android.*$ |
2 |
RewriteRule ^(.*)$ http://android.davidwalsh.name [R=301] |