-
-
Save Elvinz/e55c110a61cd04afa620b7138bb04726 to your computer and use it in GitHub Desktop.
Bitrix detect mobile devices and enable mobile template and redirect to mobile folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"]."/log.txt"); | |
//define('siteType', 'dev'); | |
//Определяем мобильные устройства библиотекой http://mobiledetect.net/ | |
require_once 'include/Mobile_Detect.php'; | |
$detect = new Mobile_Detect; | |
//Все мобилные устройства кроме планшетов | |
if( $detect->isMobile() && !$detect->isTablet() ){ | |
define('siteType', 'm'); | |
//Если еще не перешли в раздел мобильной версии сайта | |
if(preg_match('/\/m\//', $_SERVER["REQUEST_URI"]) == 0) { | |
LocalRedirect("/m".$_SERVER["REQUEST_URI"]); | |
} | |
} else { | |
define('siteType', ''); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment