帝国cms教程栏目,提供精品建站,仿站,二次开发,安装,标签使用等图文教程,帮助建设和管理好你的帝国cms站点。
帝国cms WAP模板是存在文件中的,在/e/wap/template下。访问地址全是动态的,首页地址:/e/wap/index.php ,列表地址:/e/wap/list.php?classid=2&style=0&bclassid=1,内容详情地址:/e/wap/show.php?classid=2&id=10&style=0&bclassid=1&cid=2&cpage=0。这样是不利于优化的,我们可以使用伪静态的方式来访问,要如何实现呢?下面帝国模板之家小编给大家分享一下实现方法。具体步骤如下:
1.打开index.temp.php文件,也就是首页模板,其中list.php为列表页链接,show.php为内容页链接。
找到第31行代码:
$classurl="list.php?classid=".$r[classid]."&style=".$wapstyle."&bclassid=".$bclassid;
其中classid即栏目id,style和bclassid对应模板样式和父栏目id
假设我们要把栏目页地址伪静态为 list-8.html ,我们将上面的链接代码修改为如下:
$classurl="list-".$r[classid]."html";
其他地方类似,包含list链接的地方都修改为如上的方式。
2.接下来是内容页链接地址,内容页地址是在wap版灵动标签中通过函数生成,函数在/e/wap/wapfun.php文件第527行,代码如下:
$titleurl='show.php?classid='.$r[classid].'&id='.$r[id].'&style='.$wapstyle.'&bclassid='.$class_r[$r[classid]][bclassid].'&cid='.$r[classid].'&cpage=0';
我们也将其修改为静态化的地址,这里需要注意,classid及id两项为必须,其他可忽略:
$titleurl='show-'.$r[classid].'-'.$r[id].'.html';
3.接下来我们看列表页,打开list.temp.php文件,其中的代码与上面类似,修改方式可参考上方,例如第52行定义的内容页地址:
$titleurl="show.php?classid=".$r[classid]."&id=".$r[id]."&style=".$wapstyle."&cpage=".$page."&cid=".$classid."&bclassid=".$bclassid;
4.配置伪静态规则
文件修改完之后,我们还需要相应的伪静态规则来实现地址链接的rewrite,大家可根据自己的服务器环境选择。
apache:
Options +FollowSymLinks
RewriteEngine on
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
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
}
推荐教程:帝国CMS教程
以上就是帝国cms网站Wap端如何使用伪静态的方法,更多相关内容请关注帝国模板之家。
转载请注明来源:帝国cms网站Wap端如何使用伪静态
本文永久链接地址:https://www.moyouyouw.cn/code/623.html
郑重声明:本站所有主题/文章除标明原创外,均来自网络转载,版权归原作者所有,如果有侵犯到您的权益,请联系本站删除,谢谢!我们不承担任何技术及版权问题,且不对任何资源负法律责任。
售价: 399 76 ℃ 0 评论
售价: 399 95 ℃ 0 评论
售价: 399 62 ℃ 0 评论
已有 位小伙伴发表了看法
欢迎 你 发表评论