方法一:帝国pc站跳转到手机静态站

1、假设我们有帝国cms 电脑网站www.mxxm.cc,手机网站m.mxxm.cc ,
现在电脑端和手机端都是生成静态网站,除了域名不同,静态连接地址都是相同的,例如:
www.mxxm.cc/china/1.html对应 m.mxxm.cc/china/1.html

2、接下来要给电脑网站的首页、列表页、内容页的模板添加跳转代码,方法如下:
js是浏览器跳转,meta是告诉搜索引擎移动页面的地址。
(1)首页模板需添加下面代码

try {var urlhash = window.location.hash;if (!urlhash.match(“fromapp”))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location=”http://m.mxxm.cc/”;}}}
catch(err)
{
}

(2)封面页和列表页添加下面代码

try {var urlhash = window.location.hash;if (!urlhash.match(“fromapp”))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location=”http://m.mxxm.cc”;}}}
catch(err)
{
}
<meta name=”mobile-agent” content=”format=xhtml;url=http://m.mxxm.cc”>

(3)内容页添加下面代码

try {var urlhash = window.location.hash;if (!urlhash.match(“fromapp”))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location=”http://m.mxxm.cc[!–titleurl–]”;}}}
catch(err)
{
}

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。