Answer the question
In order to leave comments, you need to log in
How to use templates and subdomains together in Yii?
Hello. There was an idea to use two templates: one for the desktop, the second for portable devices.
Now the essence of the question: how, having created two topics, to display them as, for example, done in VK: vk.com m.vk.com and where to redirect to one or another part of the application?
Answer the question
In order to leave comments, you need to log in
there is a suspicion that USER-AGENT is being dismantled in search of mobility. This is what the function in chrome "encrypt as if I'm from a computer" is built on.
Try to create a subdomain, make a common database, upload all media files and user files to a separate server or subdomain and redirect index.php to the mobile version.
<?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 || $android || $palmpre || $ipod || $berry || $mobile || $symb || $operam || $htc || $fennec || $winphone || $wp7 || $wp8 === true) {
header('Location: http://m.site.com');
}
?>
You can add a rule to urlManager
'rules' => [
'http://m.vk.com/<action:(.+)>' => '/<action>/?mobile=1',
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question