實現教程
1、首先全站僞靜態(網上搜一下就能找到教程),參考《織夢電腦站手機站僞靜態+全套僞靜態規則-自由目錄版》
只需要電腦站是僞靜態就行了,其他僞靜態教程也行,只要電腦站是僞靜態就行了
2、打開 /include/extend.func.php 在最下面加入一個方法
/**
* 判斷是否爲移動設備訪問
* @return bool
*/
function isMobile()
{
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) {
return true;
}
if (isset($_SERVER['HTTP_VIA'])) {
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$clientkeywords = array('nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile');
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) {
return true;
}
}
if (isset($_SERVER['HTTP_ACCEPT'])) {
if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'textml') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'textml')))) {
return true;
}
}
return false;
}
3、打開 /index.php 網站根目錄的 index.php ,找到
$row['templet'] = MfTemplet($row['templet']);
在它上面加入
if(isMobile()){
$row['templet'] =str_replace('.htm','_m.htm',$row['templet']);
}
4、打開 /tags.php 網站根目錄的 tags.php ,找到
require_once (dirname(__FILE__) . "/include/common.inc.php");
在它下面加入
if(isMobile()){
define('DEDEMOB', 'Y');
}
5、打開 /plus/list.php 找到
require_once(dirname(__FILE__)."/../include/common.inc.php");
在它下面加入
if(isMobile()){
define('DEDEMOB', 'Y');
}
6、打開 /plus/view.php 找到
require_once(dirname(__FILE__)."/../include/common.inc.php");
在它下面加入
if(isMobile()){
define('DEDEMOB', 'Y');
}
7、打開 /plus/search.php 找到
require_once(dirname(__FILE__)."/../include/common.inc.php");
在它下面加入
if(isMobile()){
define('DEDEMOB', 'Y');
}
8、如果你的電腦站模板裏有跳轉到手機站的跳轉代碼,記得刪除所有跳轉代碼;
9、電腦站模板文件和手機站模板文件還是按原來的命名,加個_m後綴;
10、注意手機站模板的css js images 圖片這些,防止在移動設備上打開網站時找不到這些文件;
註明:文章來自織夢俠[秩名]作者的-織夢實現url不變電腦和手機顯示不同模板