Discuz 官方給出的偽靜態規則並不完整,只實現了部分的偽靜態設置及規則,分區 gid 仍然是 forum.php?gid=xxx 的形式,對於有強迫症的我是無法忍受的,下面給出分區 gid 的偽靜態實現方法,包括論壇首頁和版塊頁,列表頁,帖子閱讀頁和論壇發帖頁(完美適用於 Discuz X2.5 以上版本,以默認風格為例)。
演示網址:http://www.bbseat.com.cn/forum.php
論壇首頁:打開 template/default/forum/discuz.htm
搜索:
forum.php?gid=$cat[fid]
替換為:
forum-$cat[fid].html
版塊頁:打開 source/module/forum/forum_forumdisplay.php
搜索:
Location: forum.php?gid=$_G[fid]
替換為:
Location: forum-$_G[fid].html
搜索:
forum.php?gid='.$forum_up['fid'].'
替換為:
forum-'.$forum_up['fid'].'.html
搜索:
forum.php?gid='.$forum_top['fid'].'
替換為:
forum-'.$forum_top['fid'].'.html
帖子頁:打開 source/module/forum/forum_viewthread.php
搜索:
? 'forum.php?gid='.$fup :
替換為:
? 'forum-'.$fup.'.html' :
這里有兩個地方需要修改。
發帖頁:打開 source/module/forum/forum_post.php
搜索:
? 'forum.php?gid='.$fup :
替換為:
? 'forum-'.$fup.'.html' :
這里也有兩個地方需要修改。
分區偽靜態規則
Nginx偽靜態規則:
rewrite ^([^\.]*)/forum-([0-9]+)\.html$ $1/forum.php?gid=$2 last;
Apache偽靜態規則:
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^forum-(\w+)\.html$ forum.php?gid=$1 [L]