Too many redirects occurred with php referer code

Hi guys :slight_smile: i have a problem with redirect code and it says on mobile devices too many redirects occurred. Any solution with this code please?

also index page added

<?php include ("gez.php"); ?>

i just want block to pc users to enter site and just let mobiles phones can access. Any solution like this?

<?

$mobile = array(  
    'Android',
    'iPod',
    'iPad',
    'iPhone',
    'webOS',
    'BlackBerry',
    'Windows Phone',
    'Windows Phone',
    'Opera Mini',
    'IEMobile',
    'Mobile'
); 


if (preg_match('@('.implode('|', $mobile).')@si', $_SERVER['HTTP_USER_AGENT']) ){ 
//if mobile enter the site  
header("Location: https://blogsitem.blog/");
die();
} else { //if pc back to google
header("Location: http://google.com.tr");
die();

}

?>

If you’re on that URL, you should not send another Location header.

If this code is being called from the index of your site, it will check for mobile, redirect to the index page…which will load the code again, and do the check again, and redirect again…which will…(repeat ad-infinitum)

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.