我們安裝了 Discuz!,如果要開啓 URL 靜態化:

需要到論壇論壇  後台---> 全局---> 優化設置--->URL 靜態化:

開啓的好處:如果一個站點都是 .html 頁面,那麼它被搜索引擎全文搜到的可能性就要比 .PHP 的頁面高几個數量級,因此而來的訪問量也會高出很多。

如果我們不檢查設置 Apache 的配置,當我們後台勾選了相應的版塊開啓 url 靜態,前台點擊版塊就會出現找不到界面的情況。

那我們就開始設置使用:

1,首先確定您使用的 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 中是否存在如下一段代碼:
我的本地是 wamp 集成的,Apache 是 2.2.6 的,默認是有的,不過要去掉註釋 (#)
LoadModule rewrite_module     modules/mod_rewrite.so
如果存在,那麼在配置文件 (通常就是 conf/httpd.conf) 中加入如下代碼。
此時請務必注意,如果網站使用通過虛擬主機來定義,請務必加到虛擬主機配置,
即<VirtualHost> 中去,如果加在虛擬主機配置外部將可能無法使用。
改好後將 Apache 重啓。

2,將下面的代碼放到 conf/httpd.conf 裏面,最好放到最後面
<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 重啓