如何压缩/更改移动版重定向代码?它使我的网站非常慢,在线压缩机无法正常工作。
<script type="text/javascript">
if((navigator.userAgent.indexOf('iPhone')!=-1)||(navigator.userAgent.indexOf('iPod')!=-1)||(navigator.userAgent.indexOf('iPad')!=-1)){document.location="http://mobile.gv.x10.mx/"}
</script>
<script type="text/javascript">
-1!=navigator.userAgent.indexOf("Android")&&(document.location="http://mobile.hj.x10.mx/");
</script>
<script>
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i))) {
location.replace("http://mobile.hj.x10.mx/");
</script>
<script>
if (screen.width <= 850) {
document.location = "http://mobile.hj.x10.mx/";
}
</script>
任何人都有更适合所有平台的更好版本吗?
答案 0 :(得分:1)
这会将所有移动设备重定向到一个页面:
# Redirect Mobile Devices
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile" [NC]
RewriteRule ^(.*)$ http://mobile.onlythebestoftheweb.x10.mx/ [R=301,L]
或者您可以将每个移动设备发送到其他页面:
# Redirect Mobile Devices
RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
RewriteRule ^(.*)$ http://mobile.onlythebestoftheweb.x10.mx/ [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
RewriteRule ^(.*)$ http://mobile.onlythebestoftheweb.x10.mx/ [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^.*Android.*$
RewriteRule ^(.*)$ http://mobile.onlythebestoftheweb.x10.mx/[R=301,L]