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

Check and redirect mobile or desktop traffic

本文关键字:桌面 流量 移动 重定向 检查      更新时间:2023-09-26

我正在开发一个html页面,用于检查流量是移动的还是桌面的。之后,如果是移动设备,它会重定向到"页面a",否则如果是台式机,它会重新定向到"页面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和/或javascript 一起使用

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

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