帝国cms网站wap端实现伪静态的方法

2019-03-2519:12:46网站建设与开发Comments2,624 views字数 1616阅读模式
Excerpt

 帝国cms的wap功能是一个实现手机版比较边界且自由度高的方法,但这其中也有一些问题,就是地址只有动态地址,这样对收录似乎并不好。

帝国cms的wap功能是一个实现手机版比较边界且自由度高的方法,但这其中也有一些问题,就是地址只有动态地址,这样对收录似乎并不好。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

这里我们以这套模板的wap端为例,来讲一下帝国cms的wap端实现伪静态的方法。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

一、wap端模板的路径文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

首先我们说明一下,wap端的模板是存储在文件当中,地址为 /e/wap/template/ ,这其中有index.temp.php  list.temp.php  show.temp.php,分别对应首页、列表页、内容页。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

二、文件修改文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

我们打开index.temp.php文件,也就是首页模板,其中list.php为列表页链接,show.php为内容页链接。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

我们在第31行看到如下代码:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

1
$classurl="list.php?classid=".$r[classid]."&style=".$wapstyle."&bclassid=".$bclassid;

其中classid即栏目id,style和bclassid对应模板样式和父栏目id,这两项可不填写。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

假设我们要把地址伪静态为 /e/wap/list-8.html ,我们将上面的链接代码修改为如下:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

1
$classurl="list-".$r[classid]."html";

其他地方类似,包含list链接的地方都修改为如上的方式。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

接下来是内容页链接地址,内容页地址是在wap版灵动标签中通过函数生成,函数在/e/wap/wapfun.php文件第527行,代码如下:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

1
$titleurl='show.php?classid='.$r[classid].'&id='.$r[id].'&style='.$wapstyle.'&bclassid='.$class_r[$r[classid]][bclassid].'&cid='.$r[classid].'&cpage=0';

我们也将其修改为静态化的地址,这里需要注意,classid及id两项为必须,其他可忽略:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

1
$titleurl='show-'.$r[classid].'-'.$r[id].'.html';

上面是首页及灵动标签中地址的修改,接下来我们看列表页,打开list.temp.php文件,其中的代码与上面类似,修改方式可参考上方,例如第52行定义的内容页地址:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

1
$titleurl="show.php?classid=".$r[classid]."&id=".$r[id]."&style=".$wapstyle."&cpage=".$page."&cid=".$classid."&bclassid=".$bclassid;

三、伪静态规则文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

文件修改完之后,我们还需要相应的伪静态规则来实现地址链接的rewrite,大家可根据自己的服务器环境选择。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

apache:
Options +FollowSymLinks
RewriteEngine on 
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

RewriteRule ^(.*)/e/wap/index.html$ $1/e/wap/index.php 
RewriteRule ^(.*)/e/wap/list-([0-9]+).html$ $1/e/wap/list.php?classid=$2 
RewriteRule ^(.*)/e/wap/show-([0-9]+)-([0-9]+).html$ $1/e/wap/show.php?classid=$2&id=$3 
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

nginx:
location / { 
rewrite ^(.*)/e/wap/index.html$ $1/e/wap/index.php 
rewrite ^(.*)/e/wap/list-([0-9]+).html$ $1/e/wap/list.php?classid=$2 
rewrite ^(.*)/e/wap/show-([0-9]+)-([0-9]+).html$ $1/e/wap/show.php?classid=$2&id=$3 
 } 
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html

 
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10335.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/cms/10335.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定