I have a mobile website and I am redirecting mobile users from main website to mobile website. But I have also given option on my mobile website that if some mobile user want to visit the main website he can. To solve the problem I wrote this code on my main website
if (is_mobile()== true) //if user is browsing from mobile
{
$main_website_url= 'http://localhost/www/redsignal/'; // main website URL
$mobilesite_url = 'http://localhost/www/redsignal-mobile/'; //mobile website URL
$mobilesite_url_length = strlen($mobilesite_url);
$referring_path_url = substr($_SERVER['HTTP_REFERER'], 0 , $mobilesite_url_length);
if ($referring_path_url == $mobilesite_url) //This if condition checks that if the mobile user is coming from my mobile website or not
{
header("Location:".$main_website_url); // if he is coming from mobile he will be redirected to main website
}
else
{
header("Location:".$mobilesite_url); // if not than he will be redirected to mobile website
}
}
You need to use another variable in order to distinguish whether you want to force show original site when click on visit original site in mobile site. For this u can pass GET variable for e.g.
http://localhost/www/redsignal/?force_show_original=1
Then in your code you change this
to
let me know whether it worked
UPDATE
Use following code to redirect site