如需要绑定域名为wap.domain.com,作下如操作:
一、把wap.domain.com域名绑定到你的这个网站主机上。
二、在网站后台模块》手机门户域名里面填写“http://wap.domain.com/”
三、在修改route.php(在caches/configs目录下),在文件中加入一行'wap.domain.com'=>array('m'=>'wap', 'c'=>'index', 'a'=>'init','data'=>array('GET'=>array('siteid'=>1))),
到这里绑定已经成功了,但是为什么要输入http://wap.domain.com/index.php才可以访问呢?直接输入http://wap.domain.com/不行吗??答案是肯定可以的,如下操作:
在首页或者在header.html里面加入以下代码:
<script>
try {if( self.location == "http://wap.domain.com/" ) {
top.location.href = "http://wap.domain.com/index.php";
}
}
catch(e) {}
</script>
那有人要问,我不要这种,我要那种如果是手机访问就直接显示手机门户网,电脑访问就直接显示普通页面可以么?答案也是可以的。如下操作:(不步骤不需要上面那串JS)
下载以下附件,放到你的网站目录里面,然后在首页模板里面或header.html里面插入JS。如
<script language="javascript" type="text/javascript" src="loca_domain.js"></script>
注:记得把loca_domain.js里面的域名改成你自己的域名哈。可能部分手机不能识别。
// JavaScript Document
var bForcepc = fGetQuery("dv") == "pc";
function fBrowserRedirect(){
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if(bIsIpad){
var sUrl = location.href;
if(!bForcepc){
window.location.href = "http://wap.domain.com/index.php";
}
}
if(bIsIphoneOs || bIsAndroid){
var sUrl = location.href;
if(!bForcepc){
window.location.href = "http://wap.domain.com/index.php";
}
}
if(bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM){
var sUrl = location.href;
if(!bForcepc){
window.location.href = "http://wap.domain.com/index.php";
}
}
}
function fGetQuery(name){//获取参数值
var sUrl = window.location.search.substr(1);
var r = sUrl.match(new RegExp("(^|&)" + name + "=([^&]*)(&|$)"));
return (r == null ? null : unescape(r[2]));
}
function fShowVerBlock(){
if(bForcepc){
document.getElementById("dv_block").style.display = "block";
}
else{
document.getElementById("ad_block").style.display = "block";
}
}
fBrowserRedirect();