tid=45014& 本帖最後由 IT_man 於 2016-8-14 21:30 編輯
1 r& O$ y- q- O; l O, T2 l3 C
. \0 r( X6 V8 A& k3 V( Q方法有二:
1 k+ i4 U+ S4 X9 w- r〖方法一〗使用.htaccess
0 G, O6 Z/ k8 a/ X1.開啟網站根目錄之.htaccess(例如/home/test/public_html)
0 ?( k- s8 n! I% X) i- RewriteEngine On
! A6 O, r4 B+ ?! u - RewriteBase /3 e9 W& b" V) {
8 {6 z+ U" T; l: u& J. N; D# C) u- RewriteCond %{QUERY_STRING} ^(.*)$
; U( G5 e4 [5 N) n( w8 Q - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1( P: z7 j# L+ q+ a h+ x3 V
- RewriteCond %{QUERY_STRING} ^(.*)$: ^3 u5 I, w' ] `1 ?; \
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1# {( z. D( k* a; h+ r# o \+ S
- RewriteCond %{QUERY_STRING} ^(.*)$
- y5 g' a* A5 E - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
2 P6 @* L. r& N* ~4 c! B - RewriteCond %{QUERY_STRING} ^(.*)$* j) q) O/ p9 x2 f5 E. O
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1' F5 G+ d8 t x9 w/ g
- RewriteCond %{QUERY_STRING} ^(.*)$
1 z8 a( n6 ]5 O' I8 Z2 s - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
+ O' ]3 X+ ]" }& o9 q8 J' F - RewriteCond %{QUERY_STRING} ^(.*)$
6 g" L$ i! [( h4 R6 g* K - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1! L5 v3 y! E7 T
- RewriteCond %{QUERY_STRING} ^(.*)$- R% j% `' D. P- z- Q% i
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1$ i' @6 K) ]/ x% y$ Q i! p& V, _8 ?
- RewriteCond %{QUERY_STRING} ^(.*)$
z' _/ v: b1 o% `7 g! Q) B - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
/ r$ z _- Q* m5 r* C/ Q
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
" b, k+ }1 Z$ ? _〖方法二〗使用Apache的rewrite(mod_rewrite)設定( P& [5 t2 ^) x5 t: V4 E/ `7 i6 n
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
6 \% Q4 L$ D* r在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內
8 R' ?/ O, i9 Q; r h增加以下內容:% v" i& E( V3 I, g' s# X$ ~
4 w2 P7 J+ c' E* R' t8 j9 D6 S- RewriteEngine On
+ ~5 M0 M4 c1 }3 a3 m; m2 F( u0 _* P - RewriteCond %{QUERY_STRING} ^(.*)$
9 c5 y3 k/ J" ?: [2 j9 V - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
; d1 I, H+ ~# V3 y7 M9 w$ A - RewriteCond %{QUERY_STRING} ^(.*)$( O' t& E) f; P& Y# _/ S
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%18 ^% o( P" }: Y& ?
- RewriteCond %{QUERY_STRING} ^(.*)$" V1 y$ r) C. T# {2 [7 n7 c
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
" L- W5 N6 R, \" e; h6 u - RewriteCond %{QUERY_STRING} ^(.*)$0 ]* y$ L1 @0 o m% i
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
) Z( Q+ Z& k# |! ~$ ]4 w1 j7 T) X) X - RewriteCond %{QUERY_STRING} ^(.*)$
; G/ l* i5 p- E# B4 {. k" j+ } - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
+ v4 l ?3 ?& T4 b - RewriteCond %{QUERY_STRING} ^(.*)$
# B* `, H3 r x/ x' i8 D - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
. ~" Q5 \" Y; Z# R - RewriteCond %{QUERY_STRING} ^(.*)$
) b( u( y# Q8 H- _ - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1( x$ i, c9 u3 P, U
- RewriteCond %{QUERY_STRING} ^(.*)$
0 `' C( K/ Q0 B1 x - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1 Z6 b ~, g/ {( {& x
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有( z7 _2 d/ O7 z. d7 v
LoadModule rewrite_module modules/mod_rewrite.so 這一行- L5 k3 q6 }6 n; C p% N
然後重啟 httpd ==> service httpd restart
9 K$ ]3 d0 D1 W
9 o# M Y, Z4 p$ l) o6 r. y4 S- y; R" u2 O; y
|