在 Linux 環境中,Discuz 論壇的偽靜態可以透過新增或修改 .htaccess 檔案來實現,流程並不複雜。
1. 先在桌面開一個記事本,把下面引用區塊中的規則內容貼進去,然後選擇「另存新檔」,存檔類型選「所有檔案」,檔名填 .htaccess。
2. 若論壇位於網站根目錄,把這個 .htaccess 上傳到根目錄即可;若論壇使用二級域名(例如 bbs.example.com),則要放進 bbs 資料夾內。
3. 特別留意規則中的 RewriteBase 這一行。它預設指向網站根目錄,如果你的論壇位址是 www.example.com/bbs,就必須改成 RewriteBase /bbs,再把檔案上傳到 bbs 資料夾。
# 開啟 RewriteEngine 模式
RewriteEngine On
# 將下面這行的 /discuz 改為你的論壇目錄;若程式放在根目錄,請改為 /
RewriteBase /
# Rewrite 系統規則請勿修改
RewriteRule ^archiver/((fid|tid)-[0-9]+\.html)$ archiver/index.php?$1
RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
RewriteRule ^space-(username|uid)-(.+)\.html$ space.php?$1=$2
RewriteRule ^tag-(.+)\.html$ tag.php?name=$1