【问题标题】:Adapt PHP Web Sites for Mobile Devices: Redirect to mobile subdomain "m"为移动设备调整 PHP 网站:重定向到移动子域“m”
【发布时间】:2021-01-28 13:52:19
【问题描述】:

我想将 html 桌面页面从“m”子域重定向到 html 移动页面。我相信我必须更改页面中的某些内容,因此我在其他网络平台上找到了一些设置。问题是,它不起作用。

在桌面页面中添加此代码(更改链接):

<link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.yoursite.com/test.html" />

<link rel="amphtml" href="https://m.yoursite.com/test.html?amp" />

在移动页面中添加这个(更改链接):

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"/>

<meta name="apple-mobile-web-app-capable" content="yes"/>

<link rel="canonical" href="https://m.yoursite.com/test.html"/>

<link rel="amphtml" href="https://m.yoursite.com/test.html?amp"/>

<link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.yoursite.com/test.html"/>

<meta name="cXenseParse:pageclass" content="article"/>

<meta name="cXenseParse:url" content="https://m.yoursite.com/test.html"/>

<meta name="robots" content="follow,index,noodp"/>

<meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1"/>

<meta name="referrer" content="origin-when-cross-origin"/>

<meta property="og:url" content="https://m.yoursite.com/test.html" />

我需要更改 php 中的某些内容吗?我必须做什么才能工作?

【问题讨论】:

    标签: php html redirect mobile


    【解决方案1】:

    可能使用Mobile-Detect,识别访问者的设备(台式机、平板电脑、智能手机),并在必要时重定向到台式机版本。是的,这就是 PHP 方面。

    【讨论】:

    • 谢谢@Curanai,但它没有说明我需要复制所有这些文件的确切位置。我应该在哪里复制这些?
    • 我不知道您的项目或其中的文件夹结构。 Mobile-Detect 是一个自己的类,有很多很多如何使用它的示例。但请记住:通常用户喜欢自行决定更改视图。您的访问者可能不需要这种自动重定向。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多