帝国CMS实现标签TAG伪静态化的方法

 本文主要分享帝国cms标签如何实现伪静态化的功能,此方法通过简单修改,实现了帝国cms中标签TAGS以TAGID的方式伪静态,可用来解决主机伪静态中文问题。

  伪静态规则,伪静态形式全部可以按照帝国原有的后台来走。(本方法修改系统文件)

  第一步添加伪静态规则:

  Linux主机直接在根目录添加,.htaccess文件,添加伪静态规则

  RewriteEngine On

  #信息内容页:showinfo-[!–classid–]-[!–id–]-[!–page–].html

  RewriteCond %{QUERY_STRING} ^(.*)$

  RewriteRule ^showinfo-(.+?)-(.+?)-(.+?)\.html$ /e/action/ShowInfo.php?classid=$1&id=$2&page=$3

  #信息列表:listinfo-[!–classid–]-[!–page–].html

  RewriteCond %{QUERY_STRING} ^(.*)$

  RewriteRule ^listinfo-(.+?)-(.+?)\.html$ /e/action/ListInfo/index.php?classid=$1&page=$2

  #标题分类列表页:infotype-[!–ttid–]-[!–page–].html

  RewriteCond %{QUERY_STRING} ^(.*)$

  RewriteRule ^infotype-(.+?)-(.+?)\.html$ /e/action/InfoType/index.php?ttid=$1&page=$2

  #TAGS信息列表页:tags-[!–tagname–]-[!–page–].html

  RewriteCond %{QUERY_STRING} ^(.*)$

  RewriteRule ^tags-(.+?)-(.+?)\.html$ /e/tags/index.php?tagname=$1&page=$2

  第二步,修改系统文件:

  打开/e/class/connect.php文件,找到

  //返回TAGS列表伪静态

  function eReturnRewriteTagsUrl

  此函数整个修改为:

  //返回TAGS列表伪静态

  function eReturnRewriteTagsUrl($tagid,$tagname,$ecms=0){

  global $public_r,$empire,$dbtbpre;

  if(!$tagid){

  $tagname=RepPostVar($tagname);

  if(!$tagname){

  $r[‘pageurl’]=$public_r[‘newsurl’];

  $r[‘rewrite’]=0;

  return $r;

  }

  $tagr=$empire->fetch1(“select tagid,num from {$dbtbpre}enewstags where tagname=’$tagname’ limit 1”);

  if(!$tagr[‘tagid’]){

  $r[‘pageurl’]=$public_r[‘newsurl’];

  $r[‘rewrite’]=0;

  return $r;

  }

  $tagid=$tagr[‘tagid’];

  }

  if(empty($public_r[‘rewritetags’])){

  $r[‘pageurl’]=$public_r[‘newsurl’].”e/tags/?tagid=”.$tagid;

  $r[‘rewrite’]=0;

  }else{

  if($ecms==1){

  $r[‘pageurl’]=$public_r[‘newsurl’].str_replace(array(‘[!–tagname–]’,'[!–page–]’),array($tagid,0),$public_r[‘rewritetags’]);

  }else{

  $r[‘pageurl’]=$public_r[‘newsurl’].str_replace(‘[!–tagname–]’,$tagid,$public_r[‘rewritetags’]);

  }

  $r[‘rewrite’]=1;

  }

  return $r;

  }

  打开/e/tags/index.php文件

  1、17 18行左右 找到:

  //TAGS

  $tagid=(int)$_GET[‘tagid’];

  修改为:

  //TAGS

  $tagid=(int)$_GET[‘tagname’];

  2、分页修改:

  193行左右找到

  if($tagr[‘tagid’]&&empty($add)&&$search==’&tagname=’.$tagname.’&line=’.$public_r[‘tagslistnum’].’&tempid=’.$public_r[‘tagstempid’])

  {

  //伪静态

  $pagefunr=eReturnRewriteTagsUrl($tagid,$tagname,0);

  $pagefunr[‘repagenum’]=0;

  //分页

  if($pagefunr[‘rewrite’]==1)

  {

  $listpage=InfoUsePage($num,$line,$page_line,$start,$page,$search,$pagefunr);

  }

  else

  {

  $listpage=page1($num,$line,$page_line,$start,$page,$search);

  }

  }

  else

  {

  $listpage=page1($num,$line,$page_line,$start,$page,$search);//分页

  }

  修改为:

  /*

  if($tagr[‘tagid’]&&empty($add)&&$search==’&tagname=’.$tagname.’&line=’.$public_r[‘tagslistnum’].’&tempid=’.$public_r[‘tagstempid’])

  {

  */

  //伪静态

  $pagefunr=eReturnRewriteTagsUrl($tagid,$tagname,0);

  $pagefunr[‘repagenum’]=0;

  //分页

  if($pagefunr[‘rewrite’]==1)

  {

  $listpage=InfoUsePage($num,$line,$page_line,$start,$page,$search,$pagefunr);

  }

  else

  {

  $listpage=page1($num,$line,$page_line,$start,$page,$search);

  }

  /*

  }

  else

  {

  $listpage=page1($num,$line,$page_line,$start,$page,$search);//分页

  }

  */