规则之树

杰奇cms防止百度转码,以及设备识别跳转代码

似乎很多人都烦过这个问题,而我这个也只是把最新的一些直接集结整理,也许现在能用不保证以后能用。而且百度转码的最终原因还是网站界面影响了用户体验,比如广告太多或者其它问题。以下的代码或许能给许多做流量的站长一点儿帮助,当然没准百度的算法之类的升级,就没有用处了,总之凑合着试试。
同理,除了杰奇之外,其它程序也可以试试,当然如果是已经转码的,想恢复就有点难。

防止转码:

<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="mobile-agent" content="format=html5; url=http://m.xxx.com" />//替换成你的手机站地址
<meta http-equiv="mobile-agent" content="format=xhtml; url=http://m.xxx.com" />//替换成你的手机站地址

设备识别跳转:
pc跳转wap

<script type="text/javascript">      
function browserRedirect() {
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(bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM){
window.location.href = "wap页面地址";
}
}
browserRedirect();
</script>

wap跳转pc

<script>
        if( navigator.userAgent.match(/Android/i)
            || navigator.userAgent.match(/webOS/i)
            || navigator.userAgent.match(/iPhone/i)
            || navigator.userAgent.match(/iPad/i)
            || navigator.userAgent.match(/iPod/i)
            || navigator.userAgent.match(/BlackBerry/i)
            || navigator.userAgent.match(/Windows Phone/i)
        ){
        }else{
        window.location.href="pc页面地址 ";
        }
</script>

<script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js" type="text/javascript"></script>
<script type="text/javascript">uaredirect("http://m.xxx.com/");</script>

伪静态和静态需要的写法以及跳转识别注意事项:

pc页面目录:{?$articleid|subdirectory?}_{?$article_id?}/
pc章节:{?$articleid|subdirectory?}_{?$article_id?}/{?$chapter_id?}.html

pc目录跳转手机目录页面,在pc目录模板里加上的跳转url路径

http://m.***.com{?$articleid|subdirectory?}_{?$articleid?}/

wap跳转pc目录页面,在手机目录模板里加上的跳转url路径

http://ww.***.com/{?$shortid?}_{?$articleid?}/

教程到此帮助,如有帮助留点评论,没有帮助,留下吐槽

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »