卡盟网站制作,最大的网站,开源企业网站,iis服务器网站301重定向怎么做本文讲解一下帝国cms电脑网站跳转到手机动态网站和手机静态网站的方法,笔者以古诗词网 www.gushichi.com为例#xff0c;为大家介绍操作步骤。方法一#xff1a;帝国pc站跳转到手机静态站
1、假设我们有帝国cms 电脑网站www.XXX.com#xff0c;手机网站m.XXX.com #xf…本文讲解一下帝国cms电脑网站跳转到手机动态网站和手机静态网站的方法,笔者以古诗词网 www.gushichi.com为例为大家介绍操作步骤。方法一帝国pc站跳转到手机静态站
1、假设我们有帝国cms 电脑网站www.XXX.com手机网站m.XXX.com 手机网站使用帝国cms的多访问端功能制作如果不了解帝国cms多访问端制作手机网站的方法
现在电脑端和手机端都是生成静态网站除了域名不同静态连接地址都是相同的例如
www.XXX.com/china/1.html对应 m.XXX.com/china/1.html
2、接下来要给电脑网站的首页、列表页、内容页的模板添加跳转代码方法如下
js是浏览器跳转meta是告诉搜索引擎移动页面的地址。
1首页模板需添加下面代码
script typetext/javascript
try {var urlhash window.location.hash;if (!urlhash.match(fromapp))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.locationhttp://m.XXX.com/;}}}
catch(err)
{
}/scriptmeta namemobile-agent contentformatxhtml;urlhttp://m.XXX.com/
2封面页和列表页添加下面代码
script typetext/javascript
try {var urlhash window.location.hash;if (!urlhash.match(fromapp))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.locationhttp://m.XXX.com?sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?;}}}
catch(err)
{
}/script
meta namemobile-agent contentformatxhtml;urlhttp://m.XXX.com?sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?
3内容页添加下面代码
添加完上面代码后帝国cms的电脑网站的每个页面都可以跳转到手机静态网站了。
但手机静态站是有缺点的每次我们更新电脑端文章都要去手机端后台重新生成一下html比较麻烦所以我们可以把手机站设置成动态访问接下来就讲解一下电脑端跳转手机动态站的方法。
方法二帝国cms电脑网站跳转到手机动态站的方法
1、首先在电脑端的多访问端设置把手机端设置成强制动态页面模式。这样手机站就是动态了不用每次都去生成html 。
2、接下来就是给电脑端模板的首页、列表页、内容页添加相依跳转代码和方法一类似。
js是浏览器跳转meta是告诉搜索引擎移动页面的地址。
1首页模板需添加下面代码
script typetext/javascript
try {var urlhash window.location.hash;if (!urlhash.match(fromapp))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.locationhttp://m.XXX.com/;}}}
catch(err)
{
}/script
meta namemobile-agent contentformatxhtml;urlhttp://m.XXX.com/
2封面页和列表页添加下面代码
script typetext/javascript
try {var urlhash window.location.hash;if (!urlhash.match(fromapp))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.locationhttp://m.XXX.com/e/action/ListInfo/?classid[!--self.classid--];}}}
catch(err)
{
}/script
meta namemobile-agent contentformatxhtml;urlhttp://m.XXX.com/e/action/ListInfo/?classid[!--self.classid--]
3内容页添加下面代码
script typetext/javascript
try {var urlhash window.location.hash;if (!urlhash.match(fromapp))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.locationhttp://m.XXX.com/e/action/ShowInfo.php?classid[!--classid--]id[!--id--];}}}
catch(err)
{
}/script
meta namemobile-agent contentformatxhtml;urlhttp://m.XXX.com/e/action/ShowInfo.php?classid[!--classid--]id[!--id--]
添加上面代码后pc网站就可以跳转到手机端的对应网页了。
注意使用上面代码时把代码中的域名改成你自己的域名就可以了。