本帖最後由 IT_man 於 2016-8-14 21:30 編輯 ( u% R: m! w4 P; n. P
6 o, x$ K' y9 k, f
方法有二:/ x+ P2 _4 {8 X5 u+ X0 Z7 B2 b
〖方法一〗使用.htaccess
2 J0 b. w& i$ X8 C3 R1.開啟網站根目錄之.htaccess(例如/home/test/public_html)- n& d9 Z5 t% g
- RewriteEngine On
- p; e! C8 {+ Z5 J* A, T - RewriteBase /7 v' T. @( U# T' s' n, y
- ) H3 }: S% k( q6 ~5 ~% r- y: Q
- RewriteCond %{QUERY_STRING} ^(.*)$
' J7 c8 W8 U' X - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
$ _. c) m: B9 K9 x - RewriteCond %{QUERY_STRING} ^(.*)$8 @0 X( M7 D; h
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
0 n' R) q+ h: q. X# g+ n - RewriteCond %{QUERY_STRING} ^(.*)$
# }4 T6 K6 s5 v) S - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%15 r% f7 K6 f) L
- RewriteCond %{QUERY_STRING} ^(.*)$
5 n; R' P5 C/ b) I C/ w! G - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%16 `- _1 J# ]+ M1 p
- RewriteCond %{QUERY_STRING} ^(.*)$
4 P9 J6 U6 H, x2 |% Y9 k# c5 }( v - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%14 V4 g+ W8 B" A* w$ z* C
- RewriteCond %{QUERY_STRING} ^(.*)$; j7 E+ u6 y$ `
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
' V& h, ]/ L4 E& O3 x - RewriteCond %{QUERY_STRING} ^(.*)$. c, Y' l- {. G$ j& Q
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1 E/ N k4 X; g7 Z: s* q
- RewriteCond %{QUERY_STRING} ^(.*)$* x! _8 O4 o$ U2 k9 D) V
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%19 v# D G% R7 }! {* D& R1 v
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效% m+ d/ o! s; Y: X
〖方法二〗使用Apache的rewrite(mod_rewrite)設定/ o. r, ]) ~! {0 ^
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
1 T M2 Q# g& c* \/ E0 K9 _在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內
% p3 p1 ^2 z- K" S/ v增加以下內容:
. s; d) P- a' Y0 e, R5 }$ g2 @$ K* J$ J
- RewriteEngine On
" e) Q0 j2 R' G3 F$ q - RewriteCond %{QUERY_STRING} ^(.*)$
8 E- n* B4 A, \; L Z - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
2 O" B' d" K) u0 d: m# ] - RewriteCond %{QUERY_STRING} ^(.*)$$ L1 n R* I/ ^: @/ d1 E
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1; P0 V0 R- M& Y% t
- RewriteCond %{QUERY_STRING} ^(.*)$
; k0 C2 Z- G9 {+ j9 t - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
1 p6 \- a% v B8 D' T - RewriteCond %{QUERY_STRING} ^(.*)$
. X( O% M/ V0 U/ B. X4 j+ u. h - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
! M1 U3 }4 Q( i3 ~ - RewriteCond %{QUERY_STRING} ^(.*)$
* f: Y, r M$ [" s - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
& Z, \8 J# Q5 d1 z S$ \6 z b - RewriteCond %{QUERY_STRING} ^(.*)$
^9 Y7 L V. q+ X2 G - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
% q, G' Y6 F- V9 j - RewriteCond %{QUERY_STRING} ^(.*)$4 d$ K" ^. Z2 j( p: ?$ ~
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%18 L9 }1 P6 g. Y7 Q- E/ m$ v3 v1 H% }
- RewriteCond %{QUERY_STRING} ^(.*)$
3 n2 y% [5 @- q9 @& X% I - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%16 y& T. @7 ~& ]( p% l! a3 {
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有) z/ j/ }- ^0 o; W2 ~; p
LoadModule rewrite_module modules/mod_rewrite.so 這一行
, C* P8 O2 x/ Z$ v1 _' M6 ~然後重啟 httpd ==> service httpd restart" {! e& }$ g; a0 ~
+ c% w# e! B2 K) ^
/ D* @& e' y* U0 w5 [4 S1 ?) k |
|