帝国cms电脑pc站url跳转到手机站url的方法

本文讲解一下帝国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 type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.XXX.com/";}}}
catch(err)
{
}</script>
 
<meta name="mobile-agent" content="format=xhtml;url=http://m.XXX.com/">

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

复制代码
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.XXX.com<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.XXX.com<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>">

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

添加完上面代码后,帝国cms的电脑网站的每个页面都可以跳转到手机静态网站了。

但手机静态站是有缺点的,每次我们更新电脑端文章,都要去手机端后台重新生成一下html,比较麻烦,所以我们可以把手机站设置成动态访问,接下来就讲解一下电脑端跳转手机动态站的方法。

方法二:帝国cms电脑网站跳转到手机动态站的方法

1、首先在电脑端的多访问端设置,把手机端设置成强制动态页面模式。这样手机站就是动态了,不用每次都去生成html 。

2、接下来就是给电脑端模板的首页、列表页、内容页添加相依跳转代码,和方法一类似。

js是浏览器跳转,meta是告诉搜索引擎移动页面的地址。

(1)首页模板需添加下面代码

复制代码
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.XXX.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.XXX.com/">

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

复制代码
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.XXX.com/e/action/ListInfo/?classid=[!--self.classid--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.XXX.com/e/action/ListInfo/?classid=[!--self.classid--]">

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

复制代码
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.XXX.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.XXX.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]">

添加上面代码后,pc网站就可以跳转到手机端的对应网页了。

注意:使用上面代码时,把代码中的域名改成你自己的域名就可以了。

相关推荐
Evand J2 天前
【MATLAB程序】Dubins曲线,车辆轨迹规划,给定起终点、半径和朝向,得到路径输出(绘图)和运动组合。附代码下载链接
开发语言·matlab·路径规划·代码·车辆·dubins
程序员鱼皮2 天前
7个神级技巧,彻底去除网站的 AI 味儿!
计算机·ai·程序员·互联网·网站·编程经验
千寻技术帮5 天前
10392_基于SpringBoot的大学迎新系统
mysql·vue·源码·springboot·代码·新生报到
千寻技术帮8 天前
10399_基于SpringBoot的智慧养老院管理系统
java·spring boot·后端·源码·安装·代码
biyezuopinvip11 天前
基于深度学习的新闻文本分类系统的研究与设计(源码)
人工智能·深度学习·分类·源码·代码·基于深度学习的·新闻文本分类系统的研究与设计
Tisfy21 天前
网站访问耗时优化 - 从数十秒到几百毫秒的“零成本”优化过程
服务器·开发语言·性能优化·php·网站·建站
爱笑的源码基地22 天前
云HIS系统源码,通过云原生部署和标准化接口,支持医保政策云同步及医共体建设
源码·云his·程序·代码·智慧医疗·医院管理信息系统·中小医院
后端开发_秋子夏23 天前
小诺AI资源中心网站正式上线了
网站·资源
week_泽23 天前
宝塔搭建自己的网站_解析域名_多个网站
宝塔·网站·域名解析·云服务器