Answer the question
In order to leave comments, you need to log in
How to redirect from the main site to mobile and vice versa?
Good evening!
Faced such a problem: there is a main site, they recently made a mobile version on a separate subdomain. The developer added a script where the device type was determined, and the person was transferred (or not transferred to the mobile version). Everything would be fine, but if he suddenly needs to switch to the full version of the site? So how to be here? I found this solution:
<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
$mobile = strpos($_SERVER['HTTP_USER_AGENT'],"Mobile");
$symb = strpos($_SERVER['HTTP_USER_AGENT'],"Symbian");
$operam = strpos($_SERVER['HTTP_USER_AGENT'],"Opera M");
$htc = strpos($_SERVER['HTTP_USER_AGENT'],"HTC_");
$fennec = strpos($_SERVER['HTTP_USER_AGENT'],"Fennec/");
$winphone = strpos($_SERVER['HTTP_USER_AGENT'],"WindowsPhone");
$wp7 = strpos($_SERVER['HTTP_USER_AGENT'],"WP7");
$wp8 = strpos($_SERVER['HTTP_USER_AGENT'],"WP8");
if($ipad || $iphone || $ipod || $android || $symb || $operam || $htc || $winphone || $berry) {
if(isset($_REQUEST['ver']) and $_REQUEST['ver'] === 'full') {
if(empty($_COOKIE['ver']))
setcookie('ver', 'full', time() + 86400, '/', '.site.ru');
} else {
header('Location: http://m.site.ru');
exit;
}
}
?>
Answer the question
In order to leave comments, you need to log in
Have you built this code into the larger version of the site?
Then, when switching to it from the mobile version, just add the argument ver=full
And there something is not done with the cookie. It is set when necessary, but not checked.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question