I have the following urls :
domain.fr (desktop site)
domain.fr/m/ (mobile site)
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 ?
okay I found the solution :
The php redirection was correct, but the code was executed for both mobile and desktop sites.
I had to make the redirection only for domain.fr, otherwise the redirection was infinited (executed also when on mobile site), and consequently Google sent this error message "dismiss".. it was not easy to understand..