2、php实现
//方法1 - $is_iPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
//方法2 - $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
- $is_pc = (strpos($agent, 'windows nt')) ? true : false;
- $is_iphone = (strpos($agent, 'iphone')) ? true : false;
- $is_ipad = (strpos($agent, 'ipad')) ? true : false;
-
- if($is_pc){
- echo "PC机"; //by http://bbs.it-home.org
- }
- if($is_iphone){
- echo "iPhone";
- }
- if($is_ipad){
- echo "iPad";
- }
- ?>
3、htaccess
- RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
- RewriteRule ^(.*)$ http://ipad.jbxue.com [R=301]
-
如果是 iPad 浏览器,跳转到 iPad 页面。 |