欢迎来到站长天空!

PHPCMS

当前位置: 主页 > CMS教程 > PHPCMS

phpcms tag页面伪静态

时间:2025-11-12 15:22:18|栏目:PHPCMS|点击:

为了SEO,我们要把tag页面伪静态,下面就是伪静态的方法

1、在后台->扩展->url规则里添加一个新的规则用于评论模块,如下面所示:

{$tag}_{$catid}_{$page}.html

添加完成后记住前面的id号,比如32。

2、打开phpcms/modules/content/tag.php文件,找到:

$total = $this->db->number;

这一行往上面添加以下代码:

$siteid = $this->categorys[$catid]['siteid'];    
$siteurl = siteurl($siteid);    
$this->db->set_model($modelid);    
$page = $_GET['page'];    
$urlrules = getcache('urlrules','commons');    
$urlrule = $urlrules[32];//调用url规则    
$datas = $infos = array();    
$infos = $this->db->listinfo("`keywords` LIKE '%$tag%'",'id DESC',$page,25,'','9',$urlrule,Array('catid'=>$catid,'tag'=>urlencode($tag)));

3、修改模板,打开phpcmstemplatesdefaultcontentshow.html,找到:

{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}

改成:

{APP_PATH}{urlencode($keyword)}_{$catid}_1.html

打开phpcmstemplatesdefaultcontenttag.html,把分页标签:

{$pages}

改成:

{str_replace("_0.html","_1.html",$pages)}

4、在.htaccess文件里加入以下代码:

RewriteRule ^(.*)_([0-9]+)_([0-9]+).html index.php?m=content&c=tag&catid=$2&tag=$1&page=$3

最后显示出来的URL样式如下:

/关键词_6_1.html

小结:其实以上的修改都是在listinfo支持伪静态规则的基础上来修改的,熟练使用listinfo,就能在phpcms的任何页面实现伪静态分页了


上一篇:phpcmsv9删除取消更新提示、屏蔽后台新版本升级提示信息

栏    目:PHPCMS

下一篇:phpcms v9最实用的23个调用代码

本文标题:phpcms tag页面伪静态

本文地址:https://zz.feitang.co/CMSjiaocheng/26104.html

广告投放 | 联系我们 | 版权申明

申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:257218569 | 邮箱:257218569@qq.com

Copyright © 2018-2025 站长天空 版权所有 Powered by EyouCms冀ICP备14023439号