Created
November 15, 2015 09:07
-
-
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
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