Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
Created November 15, 2015 09:07
Show Gist options
  • Save d1i1m1o1n/a4b19c01434fe95de7e6 to your computer and use it in GitHub Desktop.
Save d1i1m1o1n/a4b19c01434fe95de7e6 to your computer and use it in GitHub Desktop.
Bitrix detect mobile devices and enable mobile template and redirect to mobile folder
<?
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