Just Me
Just Me

Reputation: 1063

Adapt PHP Web Sites for Mobile Devices: Redirect to mobile subdomain "m"

I want to redirect html desktop pages to html mobile pages from the "m" subdomain. I believe I must change something in pages, so I find some settings on other web platforms. The problem is that, does not working.

In desktop pages add this code (change the link):

<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" />

In mobile pages add this (change the link):

<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" />

Do I need to change something in php? what do I have to do to work?

Upvotes: 1

Views: 74

Answers (1)

Curanai
Curanai

Reputation: 77

Probably use Mobile-Detect, identify the device of the visitor (desktop, tablet, smartphone) and just redirect to desktop variant if necessary. Yes, this is the PHP side.

Upvotes: 1

Related Questions