I have the following urls :
domain.fr (desktop site)
domain.fr/m/ (mobile site)
- Both urls "point" to each other using"canonical" or "alternate".
- We can access those urls without problem.
I would like to redirect people on mobile to : domain.fr/m/
in PHP, I tried :
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/(android|bb\d+).+mobile|....',substr($useragent,0,4))){header('Location: http://domain.fr/m/');}
Problem : When I check domain.fr with Google Mobile-Friendly Test, I get this error message :
(it's like Google can't check if this is mobile friendly)
If I remove the PHP above, Google can do the test but says domain.fr is NOT user-friendly.
How to make a redirection to the mobile site, I think it's a problem with the PHP code, any idea ?