公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

基于代码X3,其它版本源码,请自行验证。

Discuz后台的伪静态配置不包含门户频道页的伪静态配置。应该是考虑到频道页的URL地址变化太多的原因。下面,我们就来开发源码,加上这个功能。

第一步:加上语言包中的记录:

根目录下:sourcelanguagelang_admincp.php ,找到setting_seo_rewritestatus_portal_article 这一行,大概在1500行左右,搜索一下吧。

在这句下面加上一句:

'setting_seo_rewritestatus_portal_list' => '门户频道页',

第二步:在后台加上设置项

根目录下:sourcefunctionfunction_admincp.php ,找到rewritedata函数,在if语句的,两个大括号中,加上下面两段程序

上面一段加上

if (in_array('portal_list', $_G['setting']['rewritestatus'])) { 
            $data['search']['portal_list'] = "/" . $_G['domain']['pregxprw']['portal'] . "?mod=list&(amp;)?catid=(d+)(&page=(d+))?"([^>]*)>/e"; 
            $data['replace']['portal_list'] = "rewriteoutput('portal_list', 0, '\1', '\3', '\5', '\6')"; 
        }

下面一段加上

$data['rulesearch']['portal_list'] = 'list-{catid}-{page}.html'; 
$data['rulereplace']['portal_list'] = 'portal.php?mod=list&catid={catid}&page={page}'; 
$data['rulevars']['portal_list']['{catid}'] = '([0-9]+)'; 
$data['rulevars']['portal_list']['{page}'] = '([0-9]+)';

第三步:兼容栏目页URL地址设置

找到文件:

根目录sourcefunctionfunction_portal.php 下的函数getportalcategoryurl

重新写成下面的代码:

function getportalcategoryurl($catid) { 
    if (empty($catid)) 
        return ''; 
    loadcache('portalcategory'); 
    $portalcategory = getglobal('cache/portalcategory'); 
    if ($portalcategory[$catid]) { 
        $url = str_replace('&', '&', $portalcategory[$catid]['caturl']); 
        $url = str_replace('&', '&', $url); 
        $url = str_replace('http://'.$_SERVER['HTTP_HOST'].'/', '', $url); 
        return $url; 
    } else { 
        return ''; 
    } 
}

第四步:设置前台页面URL地址切换

根目录sourcefunctionfunction_core.php 这个文件中找到:函数rewriteoutput
在一串的if … else if中加上一段

}elseif ($type == 'portal_list') { 
        list(,,, $id, $page, $extra) = func_get_args(); 
        $r = array( 
            '{catid}' => $id, 
            '{page}' => $page ? $page : 1, 
        );

第五步:设置output_replace函数真假检索分页链接,实现伪静态

根目录sourcefunctionfunction_core.php 这个文件中找到:函数output_replace,在其代码:

$_G['setting']['output']['preg']['search']['index']='/portal.php?mod=list&catid=([0-9]+)&(amp;)?page=([0-9]+)/'; 
$_G['setting']['output']['preg']['replace']['index']="list-$1-$3.html";

$content = preg_replace($_G[‘setting’][‘output’][‘preg’][‘search’], $_G[‘setting’][‘output’][‘preg’][‘replace’], $content);上方加入下面两行代码

第六步:设置iis或Apache的伪静态规则

Discuz系统设置里面有伪静态的规则,自动生成的。全局-》SEO设置-》查看当前的 Rewrite 规则,找到规则就加载到iis或apache上面,这就大公告成了!

分享到:
标签:分页 开发 栏目 门户 静态
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定