本帖最後由 IT_man 於 2016-8-14 21:30 編輯
7 W1 L9 c( {8 c% U; f
* b8 q2 w2 I/ d4 ^0 N方法有二:
1 q% K: F8 i+ z! G2 y: v〖方法一〗使用.htaccess( ^. o' }3 t& f, @! {( ~
1.開啟網站根目錄之.htaccess(例如/home/test/public_html)
& W( A1 b( X. C- RewriteEngine On+ f; Z+ F) ]3 H% ^; g. n
- RewriteBase /
1 @7 o: ~0 H1 m C- w# J - 4 Q% i* C# X: f; l
- RewriteCond %{QUERY_STRING} ^(.*)$% |) O3 O+ U& S1 |6 Z( V
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1& F1 _! w6 u1 m! f8 f- g2 I% b
- RewriteCond %{QUERY_STRING} ^(.*)$6 I, n4 e8 p3 q- J: a; M
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%10 ?: n- `: x: k, z6 u/ x0 j
- RewriteCond %{QUERY_STRING} ^(.*)$8 M# v0 W$ N0 m6 f+ v3 E# y
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%17 z q! w; W8 O0 r' j: j
- RewriteCond %{QUERY_STRING} ^(.*)$$ _1 ~3 u/ b8 ^
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%15 @: k3 E# x: M
- RewriteCond %{QUERY_STRING} ^(.*)$
' O0 u T$ p4 [% V6 ~- l - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
8 G2 a9 x/ D9 X/ m/ m! e - RewriteCond %{QUERY_STRING} ^(.*)$
2 V6 ^: E/ ~' w1 O ? - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
3 s7 A2 C4 E9 C! B+ E - RewriteCond %{QUERY_STRING} ^(.*)$
! p% ?- x4 _2 d" `- p5 w: [" q) Q - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
0 H1 t& o" l9 y6 H4 o9 k - RewriteCond %{QUERY_STRING} ^(.*)$
) c7 \1 q- o% P- m) m* S& T2 ?: z4 A6 ] - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
% @. C: S9 }/ Z, }" |
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效* U, K* L8 a/ m
〖方法二〗使用Apache的rewrite(mod_rewrite)設定
" m$ O% j) I. V8 G5 |1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
8 f; f! w( [$ N3 X& x. d在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內" _; Z E5 Z/ K1 k, n
增加以下內容:
% i! N2 M% p2 D2 z% O: A) M8 O' d: q' l& `4 n# Z( q5 ]7 I+ m2 {
- RewriteEngine On V3 D( j- I0 D- `
- RewriteCond %{QUERY_STRING} ^(.*)$
; ?3 f, y/ m. d0 c. e& |# k( g6 | - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
. \! ]( U& f( [) j+ C - RewriteCond %{QUERY_STRING} ^(.*)$
3 B S6 t1 X$ g* F - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1' b& A1 b; q' e( F
- RewriteCond %{QUERY_STRING} ^(.*)$" G+ X' ]! \6 a' g' |2 c! j
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%11 i+ P9 | ~8 I) O9 u
- RewriteCond %{QUERY_STRING} ^(.*)$
( e+ I( V& e5 G - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1$ ~5 X5 B1 `+ C0 B) C- j
- RewriteCond %{QUERY_STRING} ^(.*)$- ?0 L, v9 Q+ V
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
+ ~ I3 a7 J4 _% o - RewriteCond %{QUERY_STRING} ^(.*)$( {+ f8 U) ^7 a2 `
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%14 P) B& X1 L t5 O- @
- RewriteCond %{QUERY_STRING} ^(.*)$
W0 S! Y: B" X: _" |1 F - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1- S3 F, ?9 G _ Y
- RewriteCond %{QUERY_STRING} ^(.*)$( ?2 n4 d, P! |$ R2 Y* M$ c
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
A/ g4 p6 j4 H" o% m/ d& ?* [
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有+ V2 K* v/ ^' I ` b4 m
LoadModule rewrite_module modules/mod_rewrite.so 這一行
3 X( Q) M- q# W0 a然後重啟 httpd ==> service httpd restart! {" B4 ~! G N7 @7 A2 ?
2 j% f* I# D. F) m) |, W
* G& z0 i' m8 \% X# x |
|