discuz如何板块和帖子目录化URL伪静态?

据说网站权重是:二级域名>目录>静态页>动态页。discuz板块和帖子目录化URL伪静态,效果如下:

板块URL样式:http://zhishi.zhanad.com/bankuai/

帖子URL样式:http://zhishi.zhanad.com/bankuai/t339.html

打开source\function下的function_core.php查找

if($type == 'forum_forumdisplay') {
       list(,,, $fid, $page, $extra) = func_get_args();
       $r = array(
               '{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
               '{page}' => $page ? $page : 1,
           );
       } elseif($type == 'forum_viewthread') {
           list(,,, $tid, $page, $prevpage, $extra) = func_get_args();
           $r = array(
               '{tid}' => $tid,
               '{page}' => $page ? $page : 1,
               '{prevpage}' => $prevpage && !IS_ROBOT ? $prevpage : 1,
       );

将上述代码修改为:

if($type == 'forum_forumdisplay') {
            list(,,, $fid, $page, $extra) = func_get_args();
            $r = array(
                '{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
                '{page}' => $page ,
            );
        } elseif($type == 'forum_viewthread') {
            list(,,, $tid, $page, $prevpage, $extra) = func_get_args();
            $fid = DB::result_first("SELECT fid FROM ".DB::table('forum_thread')." WHERE tid = '$tid'");
            $r = array(
                '{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
                '{tid}' => $tid,
                '{page}' => $page ,
                '{prevpage}' => $prevpage && !IS_ROBOT ? $prevpage : 1,
        );

网站后台->全局->”seo设置”->”url静态化”在”论坛主题列表页”的格式中填写:{fid}/{page}在”论坛主题内容页”的格式中填写:{fid}/m{tid}/{page}
在伪静态规则(.htaccess文件,一般在根目录下),记事本打开,在最后添加如下规则:

## 保留前面的部分可以不影响已经被搜索引擎收录的页面
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule /m([0-9]+)(/([0-9]+))?(/)?$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$5&page=$3&%1 [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^([0-9a-z_]+)(/([0-9]+))?(/)?$ forum.php?mod=forumdisplay&fid=$1&page=$3&%1 [L,NC]

来源/建站笔记

发表评论

昵称

沙发空缺中,还不快抢~