php - 为移动设备调整 PHP 网站:重定向到移动子域“m”
问题描述
我想将 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 中的某些内容吗?我必须做什么才能工作?
解决方案
可能使用Mobile-Detect,识别访问者的设备(台式机、平板电脑、智能手机),并在必要时重定向到台式机变体。是的,这是 PHP 方面。
推荐阅读
- c# - 在视图组件或局部视图中使用表单
- spring-boot - 难以将 1 个父类与 3 个子类的 OneToOne 关系映射
- python - 将字符串编号连接到系列索引的开头
- java - 如果已经加载了 Admob 插页式广告,如何避免加载?
- elixir - 测试在具有关联的模式上工作的 elixir 控制器
- javascript - 传单和开放的街道地图停止工作?
- python - PYTHON 中的 RECURSION 使所有可能的排列不重复
- android - 为工具栏下方的 Searchview 创建的与 ListView 重叠的组件
- neo4j - 根据条件在密码中创建关系
- matlab - Simulink:输出参数“mot_trq_dem”未在某些执行路径上分配