首頁
相簿
論壇
訂閱最新文章

星期日, 8月 17, 2008

Discuz! URL 靜態化

Apache Web Server(獨立主機用戶)

首先確定您使用的 Apache 版本,及是否加載了 mod_rewrite 模塊。

Apache 1.x 的用戶請檢查 conf/httpd.conf 中是否存在如下兩段代碼:
LoadModule rewrite_module libexec/mod_rewrite.so

AddModule mod_rewrite.c


Apache 2.x 的用戶請檢查 conf/httpd.conf 中是否存在如下一段代碼:
LoadModule rewrite_module modules/mod_rewrite.so



如果存在,那麼在配置文件(通常就是 conf/httpd.conf)中加入如下代碼。此時請務必注意,如果網站使用通過虛擬主機來定義,請務必加到虛擬主機配置,即 中去,如果加在虛擬主機配置外部將可能無法使用。改好後然後將 Apache 重啟。
<IfModule mod_rewrite.c>
                RewriteEngine On
                RewriteRule ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2
                RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
                RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
                RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3
                RewriteRule ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2
        </IfModule>

Apache Web Server(虛擬主機用戶)

在開始以下設置之前,請首先咨詢您的空間服務商,空間是否支持 Rewrite 以及是否支持對站點目錄中 .htaccess 的文件解析,否則即便按照下面的方法設置好了,也無法使用。

檢查論壇所在目錄中是否存在 .htaccess 文件,如果不存在,請手工建立此文件。Win32 系統下,無法直接建立 .htaccess 文件,您可以從其他系統中拷貝一份,或者在 Discuz.net 技術支持欄目中下載此文件。編輯並修改 .htaccess 文件,添加以下內容
# 將 RewriteEngine 模式打開 RewriteEngine On

 # 修改以下語句中的 /discuz 為你的論壇目錄地址,如果程序放在根目錄中,請將 /discuz 修改為 / RewriteBase /discuz
 # Rewrite 系統規則請勿修改
 RewriteRule ^archiver/((fid|tid)-[\w\-]+\.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

添加內容時,請遵照上面的提示,修改論壇所在的路徑,然後保存。將 .htaccess 文件上傳到論壇所在的目錄中。然後進入論壇系統設置的搜索引擎優化,根據需要開啟 URL 靜態化功能。

更多訊息請參考官方連結

張貼者:甄咖郎 於 上午10:37:00  

0 意見:

張貼留言