gpt4 book ai didi

mobile - Googlebot 桌面被检测为移动设备

转载 作者:行者123 更新时间:2023-12-05 07:51:03 27 4
gpt4 key购买 nike

我正在迁移桌面网站以通过一组单独的 URL 支持移动设备。在网站的根目录,我使用媒体查询来检测用户是移动设备还是桌面设备,然后重定向到适当的区域。

出于某种原因,桌面版 Googlebot(使用 Google Search Console 的“Fetch as Google”)正在作为移动版出现。它被检测为基于以下媒体查询的移动...

@media all and (max-width: 1024px) {  ... }

我能够确定视口(viewport)宽度/高度为 1024 x 768。因此,Googlebot 桌面使用平板电脑尺寸。

当使用“Fetch as Google”作为智能手机时,它显示为 980 x 1743。根据媒体查询,这被正确检测为移动设备...

@media all and (max-width: 768px) { ... }

什么给了?我是否需要为 Googlebot 安装特殊的用户代理来检测桌面或移动设备?

有没有更好的方法来检测可以与 Googlebot 正常工作的移动设备或桌面设备?不想不得不诉诸检查不同移动设备用户代理的 1000 个可能的字符串。媒体查询检查在真实设备上运行良好。

最佳答案

您可以使用方向查询:

@media all and (orientation: portrait) {
p {
color: red;
}
}

@media all and (orientation: landscape) {
p {
color: purple;
}
}
<body>
<p>Resize to change color</p>
</body>

关于mobile - Googlebot 桌面被检测为移动设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35567423/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com