本帖最後由 IT_man 於 2016-8-14 21:30 編輯 ! G$ F/ k( T3 F, ^3 w5 X
J9 c6 C! }9 d8 [5 E3 v) B- C6 U9 }方法有二:
2 o2 U0 l# [- j7 X〖方法一〗使用.htaccess
( y" j; J# [7 i7 b1.開啟網站根目錄之.htaccess(例如/home/test/public_html)& G3 s" d* ^$ G* ?9 B+ L
- RewriteEngine On
/ z+ P) c8 d! V4 w c5 W U2 f - RewriteBase /
( l! G, g0 r; S/ k+ y3 ? - - F4 ]8 O0 F' V6 |
- RewriteCond %{QUERY_STRING} ^(.*)$
, M) Z$ _( g/ A& r p2 j+ S - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
+ b* U4 [, w `4 L - RewriteCond %{QUERY_STRING} ^(.*)$% t9 D) d* p6 }* Q6 V
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
1 o! Q2 g" e9 @3 l* @& E - RewriteCond %{QUERY_STRING} ^(.*)$
1 M% m& ?& M* @, d/ ` - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1) T9 |/ h4 U) G7 W
- RewriteCond %{QUERY_STRING} ^(.*)$
5 d* ?2 O" Q6 m - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1; w/ e2 g0 o2 Y6 r; y; d8 O
- RewriteCond %{QUERY_STRING} ^(.*)$# f; J: B/ ~! D- p1 k5 r; k
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%12 W9 [: Z; w3 ` o Q1 `4 x1 ~
- RewriteCond %{QUERY_STRING} ^(.*)$2 h7 ~2 V& K; x6 a+ j
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
- B+ X# ^; z1 a# @ - RewriteCond %{QUERY_STRING} ^(.*)$
) _& L3 i4 m3 ] - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
0 m9 N2 k. V5 i - RewriteCond %{QUERY_STRING} ^(.*)$
4 p6 Q, }7 f5 f7 A8 s4 f' W+ Q# T, F - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1+ l% \; ?& X6 s$ \, p s
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
% T6 v! Q, ?! K+ j# i, O〖方法二〗使用Apache的rewrite(mod_rewrite)設定4 j* q, @( S" D7 n5 q5 ?& `" M
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
6 `0 z8 p8 p. J8 p9 C! [在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內5 X; r! x7 Y5 M, @) c! e' B
增加以下內容:
1 P) i C# C6 Q o, l" J; W0 G; Y5 Q' T" Q4 T% _
- RewriteEngine On# J7 E. l0 W' |' p& v& P
- RewriteCond %{QUERY_STRING} ^(.*)$
) n: w. \# I! {( p" i% ^" a - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
% F3 B- ^2 @) j: v3 E9 _3 W - RewriteCond %{QUERY_STRING} ^(.*)$0 C3 b- D- { c
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
2 o8 S0 o, S/ J g* r3 Q - RewriteCond %{QUERY_STRING} ^(.*)$
! ?" r& w, e; n. p; B - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
[) D5 Q: @1 g0 c4 W - RewriteCond %{QUERY_STRING} ^(.*)$- } t$ J6 u$ \. Q& `7 j8 U
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
9 x! D9 I% m1 r9 c$ {0 Y& k7 g - RewriteCond %{QUERY_STRING} ^(.*)$
! H1 b& B5 P- \5 w* j - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%11 [/ o+ T, p1 q* v
- RewriteCond %{QUERY_STRING} ^(.*)$& k. p( u* ?6 `& z! D
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
8 b* X1 S) U8 X2 I9 ]! c - RewriteCond %{QUERY_STRING} ^(.*)$& G6 f1 z8 c7 f
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
( o/ n3 H) [* U0 ]4 j# D - RewriteCond %{QUERY_STRING} ^(.*)$
# o' U( b) J4 u) s6 t - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%19 H, t* E# ?- K3 K' L+ |2 e
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有9 T& F# \ x" @$ Z' _
LoadModule rewrite_module modules/mod_rewrite.so 這一行
Y! O0 @4 |) J9 O) i6 C6 a然後重啟 httpd ==> service httpd restart
& r& i9 u% [+ f" B! j/ c0 i8 H5 B' @0 [
$ P" M5 p4 X% I3 l" _1 D3 g+ s
|
|