当前位置:「千越SEO」 / 网站维护 / 帝国CMS 7.5 实现搜索页伪静态

帝国CMS 7.5 实现搜索页伪静态

来源:千越SEO
浏览:29

版本:帝国CMS 7.5 UTF8

实现效果:http://www.xxx.com/search-0-30.html

一、打开e/search/index.php,Ctrl+F找到:

Header("Location:result/?searchid=$searchid".$dogetvar);

修改为:

Header("Location:$public_r[newsurl]search-0-$searchid.html".$dogetvar);

二、打开e/search/result/index.php,Ctrl+F找到:

//搜索结果

$searchid=(int)$_GET['searchid'];

在它前面添加:

//增加分页函数
function page10($num,$line,$page_line,$start,$page,$search){
global $fun_r;
if($num<=$line)
{
return '';
}
$search=RepPostStr($search,1);
$url=$public_r['newsurl'].'search';
$snum=2;//最小页数
$totalpage=ceil($num/$line);//取得总页数
$firststr='<a title="'.$fun_r['trecord'].'">&nbsp;'.$num.'&nbsp;</a>&nbsp;&nbsp;';
//上一页
if($page<>0)
{
$toppage='<a href="'.$url.'-0-'.$search.'.html">'.$fun_r['startpage'].'</a>&nbsp;';
$pagepr=$page-1;
$prepage='<a href="'.$url.'-'.$pagepr.'-'.$search.'.html">'.$fun_r['pripage'].'</a>';
}
//下一页
if($page!=$totalpage-1)
{
$pagenex=$page+1;
$nextpage='&nbsp;<a href="'.$url.'-'.$pagenex.'-'.$search.'.html">'.$fun_r['nextpage'].'</a>';
$lastpage='&nbsp;<a href="'.$url.'-'.($totalpage-1).'-'.$search.'.html">'.$fun_r['lastpage'].'</a>';
}
$starti=$page-$snum<0?0:$page-$snum;
$no=0;
for($i=$starti;$i<$totalpage&&$no<$page_line;$i++)
{
$no++;
if($page==$i)
{
$is_1="<b>";
$is_2="</b>";
}
else
{
$is_1='<a href="'.$url.'-'.$i.'-'.$search.'.html">';
$is_2="</a>";
}
$pagenum=$i+1;
$returnstr.="&nbsp;".$is_1.$pagenum.$is_2;
}
$returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage;
return $returnstr;
}

三、打开e/search/result/index.php,Ctrl+F找到:

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

修改为:

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

四、打开e/search/result/index.php,Ctrl+F找到:

$search="&searchid=".$searchid;

修改为:

$search="$searchid";

五、添加伪静态规则

Apache Rewrite:RewriteRule ^search-(.+?)-(.+?).html$ /e/search/result/index.php?page=$1&searchid=$2;
Nginx Rewrite:rewrite ^/search-(.+?)-(.+?).html$ /e/search/result/index.php?page=$1&searchid=$2;
本文地址:https://www.seoo.net/maint/1618.html
标签:
下一篇:无
  • qq
  • 微信咨询
  • 扫一扫,微信咨询