将移动设备重定向到我网站的备用版本 [英] Redirect mobile devices to alternate version of my site

查看:22
本文介绍了将移动设备重定向到我网站的备用版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经为移动设备准备了一个备用版本的网站.我们提供的内容不同,而且效果很好.

We've got an alternate version of out website ready for mobile devices. The content we serve is different and it works well.

检测要提供哪个版本的最佳方法是什么.我们没有所有移动设备的列表,因此使用用户代理标头很棘手,因为我们可能会遗漏一些东西.

What is the best way to detect which version to serve. We don't have a list of all mobile devices so to use the user-agent header is tricky as we may miss something.

我们考虑过使用设备屏幕宽度 - 但是如果移动设备不支持 javascript 会发生什么.我们如何嗅探这个?

We thought about useing device screen width - but what happens if the mobile device doesnt support javascript. How do we sniff this ?

推荐答案

您可以使用设备描述数据库(例如 WURFL) 它将从请求标头中识别客户端设备.然后,您可以查询该数据库以确定设备是否可以处理您的站点(例如,支持 javascript,或者屏幕是否足够大),然后再决定是否将它们重定向到其他站点.

You could use a device description database (such as WURFL) which will recognise the client device from the request headers. You can then query that database to decide if the device can handle your site (e.g. support javascript, or is the screen big enough) before deciding whether to redirect them to a different site.

您没有提到您的环境,但 WURFL 提供了适用于 Java 和 PHP 的 API,也许还有其他 API.如果没有提供 API,您仍然可以使用 WURFL,但您必须自己解析和处理 XML 数据.

You don't mention your environment, but WURFL supplies APIs for Java and PHP, and maybe others as well. If there's no supplied API, you can still use WURFL, but you'll have to parse and process the XML data yourself.

这篇关于将移动设备重定向到我网站的备用版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆