检查并重定向移动或桌面流量

Check and redirect mobile or desktop traffic

我正在开发一个 html 页面来检查流量是移动设备还是桌面设备。之后,如果是移动设备,它会重定向到 "page A",否则如果是桌面设备,它会重定向到 "page B".

目前我有此代码,但不适用于移动设备,重定向仅适用于桌面流量。

我该如何解决?

<html>
<head>
<script>if (typeof window.orientation == 'undefined' || len(navigator.plugins.length) > 0){
            document.location.href='http://pageA';
            }
    else {
            document.location.href='http://pageB';
            }</script>

<title>My test</title>


</head>

<body>

</body>
</html>

我在 .htaccess 中使用了这个实现 and/or javascript

它需要对您想要的结果进行一些修改,但两种解决方案都提供了一种可靠的检测和重定向方法 -

http://www.inmotionhosting.com/support/website/redirects/mobile-redirect