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

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

问题描述

我们有一个替代版本的网站,适用于移动设备。我们所服务的内容是不同的,它运作良好。

检测要提供哪个版本的最佳方法是什么?我们没有所有移动设备的列表,所以要使用用户代理标题是棘手的,因为我们可能会错过某些东西。



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

解决方案

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



你没有提到你的环境,但是WURFL提供了用于Java和PHP的API,或者其他的API。如果没有提供API,您仍然可以使用WURFL,但您必须自己解析和处理XML数据。


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.

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

解决方案

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.

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天全站免登陆