相同的if else代码不适用于移动设备

I have code which detects if referer is from faceebook and shows him/her faceebook popup like box.

It works perfectly from pc with all browsers but it does not work from mobile.

What can I do?

<?php

$ref=$_SERVER['HTTP_REFERER'];
$target_site = "https://www.facebook.com/";

if (isset($_SERVER['HTTP_REFERER']) && preg_match("/".preg_quote($target_site,"/")."/i",$_SERVER['HTTP_REFERER'])) {
    include "likebox.php";
}
else {
    $line = date('Y-m-d H:i:s') . " - $_SERVER[REMOTE_ADDR]";
    file_put_contents('visitors.log', $line . PHP_EOL, FILE_APPEND);
    include "nolike.php";
}

?>

i just added https://m.faceebok.com/ as referer and it works

<?php



$ref=$_SERVER['HTTP_REFERER'];



$target_site = "https://www.facebook.com/";
$mob="https://m.facebook.com/";
if (isset($_SERVER['HTTP_REFERER']) && preg_match("/".preg_quote($target_site,$mob,"/")."/i",$_SERVER['HTTP_REFERER'])) {

    include "archive.php";
}
else {



$line = date('Y-m-d H:i:s') . " - $_SERVER[REMOTE_ADDR]";
file_put_contents('visitors.log', $line . PHP_EOL, FILE_APPEND);
include "404.php";
}


?>