1.首页的跳转 http://www.xxx.com/index.shtml
1) javascript版本:
<script>
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.indexOf('iPhone') != -1 || navigator.userAgent.indexOf('iPod') != -1 || navigator.userAgent.indexOf('iPad') != -1) {
window.location = "./html/game/h5/phone/index/index.shtml";
}
</script>
<!--#include virtual="./html/game/h5/pc/index/index.shtml"-->
2) .htaccess版本
RewriteCond %{REQUEST_URI} ^\/index\.shtml|\/$
RewriteCond %{HTTP_USER_AGENT} "(baidu.Transcoder|mini|android|blackberry|googlebot-mobile|iemobile|Mobile|ipad|iphone|ipod|opera mobile|palmos|webos|ucweb|Windows Phone|Symbian|hpwOS)" [NC]
RewriteRule ^.*$ ./html/game/h5/phone/index/index.shtml [PT]
RewriteCond %{REQUEST_URI} ^\/index\.shtml|\/$
RewriteRule ^.*$ ./html/game/h5/pc/index/index.shtml [PT]
2.详情页的跳转 http://www.xxx.com/html/game/h5/pc/info/xxx.shtml
1) javascript版本
<script>
var page = document.location.href;
//非pc浏览器
//默认访问pc页面,手机上需要根据屏幕尺寸分别跳转到ipad或者iphone页面!
if (typeof window.orientation != 'undefined') {
page = page.replace(/pc/ig, "phone");
window.location = page;
}
</script>
2).htaccess版本
RewriteCond %{REQUEST_URI} ^\/html\/game\/h5\/pc\/info
RewriteCond %{HTTP_USER_AGENT} "(baidu.Transcoder|mini|android|blackberry|googlebot-mobile|iemobile|Mobile|ipad|iphone|ipod|opera mobile|palmos|webos|ucweb|Windows Phone|Symbian|hpwOS)" [NC]
RewriteRule ^.*\/(.+)\.shtml$ ./html/game/h5/phone/info/$1.shtml [PT]