[技术文章] discuz3.4 主体分类伪静态修改方法

[复制链接]
作者
n2n1   发布于2021-4-13 03:13:54 来自河北
\source\function\function_admincp.php
查找:(约1250~1253行)

  1. <font size="2">if(in_array('forum_forumdisplay', $_G['setting']['rewritestatus'])) {
  2.                         $data['search']['forum_forumdisplay'] = "/".$_G['domain']['pregxprw']['forum']."\?mod\=forumdisplay&(amp;)?fid\=(\w+)(&page\=(\d+))?"([^\>]*)\>/";
  3.                         $data['replace']['forum_forumdisplay'] = 'rewriteoutput(\'forum_forumdisplay\', 0, $matches[1], $matches[3], $matches[5], $matches[6])';
  4.                 }
  5. </font>
复制代码
在其下行添加:
  1. <font size="2">if(in_array('forum_forumdisplay_type', $_G['setting']['rewritestatus'])) {
  2.     $data['search']['forum_forumdisplay_type'] = "/".$_G['domain']['pregxprw']['forum']."\?mod\=forumdisplay&(amp;)?fid\=(\w+)(&typeid\=(\w+))?(&filter\=typeid)?(&typeid\=(\w+))?(&filter\=typeid)?(&page\=(\d+))?"([^\>]*)\>/e";
  3.     $data['replace']['forum_forumdisplay_type'] = "rewriteoutput('forum_forumdisplay_type', 0, $matches[1], $matches[3], $matches[8], $matches[11], $matches[12])";
  4. }</font>
复制代码
查找:(约1299~1302行)
  1. <font size="2">$data['rulesearch']['forum_forumdisplay'] = 'forum-{fid}-{page}.html';
  2.                 $data['rulereplace']['forum_forumdisplay'] = 'forum.php?mod=forumdisplay&fid={fid}&page={page}';
  3.                 $data['rulevars']['forum_forumdisplay']['{fid}'] = '(\w+)';
  4.                 $data['rulevars']['forum_forumdisplay']['{page}'] = '([0-9]+)';</font>
复制代码
在其下行添加:
  1. <font size="2">$data['rulesearch']['forum_forumdisplay_type'] = 'forum-{fid}-{typeid}-{page}.html';
  2. $data['rulereplace']['forum_forumdisplay_type'] = 'forum.php?mod=forumdisplay&fid={fid}&filter=typeid&typeid={typeid}&page={page}';
  3. $data['rulevars']['forum_forumdisplay_type']['{fid}'] = '(\w+)';
  4. $data['rulevars']['forum_forumdisplay_type']['{typeid}'] = '(\w+)';
  5. $data['rulevars']['forum_forumdisplay_type']['{page}'] = '([0-9]+)';</font>
复制代码
编辑:
\source\function\function_core.php

  1. <font size="2">if($type == 'forum_forumdisplay') {
  2.                 list(,,, $fid, $page, $extra) = func_get_args();
  3.                 $r = array(
  4.                         '{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
  5.                         '{page}' => $page ? $page : 1,
  6.                 );</font>
复制代码
在其下行添加elseif:
  1. <font size="2"> elseif($type == 'forum_forumdisplay_type') {
  2.     list(,,, $fid, $typeid, $page, $extra) = func_get_args();
  3.     $r = array(
  4.     '{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
  5.     '{typeid}' => $typeid,
  6.     '{page}' => $page ? $page : 1,
  7.     );}</font>
复制代码
/source/language/lang_admincp.php
查找:(约1509行)
  1. <font size="2">'setting_seo_rewritestatus_forum_forumdisplay' => '论坛主题列表页',</font>
复制代码
在其下行添加:
  1. <font size="2">'setting_seo_rewritestatus_forum_forumdisplay_type' => '论坛主题分类页',</font>
复制代码
勾选提交之后,点击右上角“查看当前的 Rewrite 规则”
在你的伪静态规则添加你对应主机类型的相关伪静态规则,
举个例子,比如
Apache Web Server(虚拟主机用户)环境:
.htaccess 添加如下规则,即可生效。
伪静态规则:
  • RewriteCond %{QUERY_STRING} ^(.*)$
  • RewriteRule ^forum-(\w+)-(\w+)-([0-9]+)\.html[        DISCUZ_CODE_160        ]nbsp;forum.php?mod=forumdisplay&fid=$1&filter=typeid&typeid=$2&page=$3&%1

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 创建账号

本版积分规则

Archiver|小黑屋|( 冀ICP备2021005463号 )

GMT+8, 2024-11-21 18:59 , Processed in 0.117239 second(s), 28 queries , Gzip On.

N2N1 It社区 n2n1.cn

Copyright © 2001-2021,MeiCheng.

快速回复 返回顶部 返回列表