本帖最後由 IT_man 於 2016-8-14 21:30 編輯
3 G: t" k4 R0 o$ N" y
7 _8 L/ x1 l. T, o- Z方法有二:
1 e5 V; u3 g4 z1 \, _8 t" ^〖方法一〗使用.htaccess% c H3 v: H1 ]$ Y" p& S
1.開啟網站根目錄之.htaccess(例如/home/test/public_html)7 [5 [* Y5 O+ {+ }- S
- RewriteEngine On
/ X% D, `, x; U# W, @& v8 d - RewriteBase /1 H6 s' c" E" {$ |( o7 b
- y: |, `9 \6 |" J/ K# L' @
- RewriteCond %{QUERY_STRING} ^(.*)$( ^! ^( G: V0 S
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1! u+ m; {9 G/ m/ ]
- RewriteCond %{QUERY_STRING} ^(.*)$" A9 P% [( x3 @0 k' j, H
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1' P2 J+ Z L, V5 o1 M
- RewriteCond %{QUERY_STRING} ^(.*)$: e K* W8 ^3 K8 S7 W
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1; n" y! H$ u4 g0 ?! c; l+ K: ?: c
- RewriteCond %{QUERY_STRING} ^(.*)$5 c% D$ e5 O0 l/ V* o+ Y
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
! Y& w. o& N- a- Z B0 F( x - RewriteCond %{QUERY_STRING} ^(.*)$6 e- A. b% g* D `. u2 ]3 s& x! f
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
, L: c4 A0 a8 J- L - RewriteCond %{QUERY_STRING} ^(.*)$
7 j7 v+ N" \0 m% p0 q7 W6 ^- [- ~ - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1( l) @4 S# y- ]& j R
- RewriteCond %{QUERY_STRING} ^(.*)$, V( e$ Q' o, {5 k! s1 \- N
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1, m. _7 c" c L# m( R) b5 R6 J
- RewriteCond %{QUERY_STRING} ^(.*)$
# G& I7 p ^8 o0 `2 D5 Y' C' j/ | - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
' S/ u! X8 V; d. j. U; r; t
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效3 b2 [5 F" d# F4 v
〖方法二〗使用Apache的rewrite(mod_rewrite)設定: h6 x6 L- j& c9 l6 \, `7 [! P
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或 a4 R$ D+ ~1 n! {& M6 u0 ^
在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內5 \4 Q& i" V% A/ V; h ]* L
增加以下內容:- v3 U; }# L! e
; Y0 r* [/ A/ K; X8 M- R3 t
- RewriteEngine On
4 S3 W9 N4 Q% @ - RewriteCond %{QUERY_STRING} ^(.*)$
& j0 y6 j9 y3 V' R7 M5 [7 @ - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
0 t, q6 E! F# S. ~, k - RewriteCond %{QUERY_STRING} ^(.*)$
" u7 s3 ]2 ?, B9 [ - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
& h5 y! i0 }% G A - RewriteCond %{QUERY_STRING} ^(.*)$
% I! W) O/ R0 d; v& y' w - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%11 V$ _& p% j! {' j2 C0 N
- RewriteCond %{QUERY_STRING} ^(.*)$
/ Q7 ?# {2 K) L# I+ n! q - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
3 v! X' X$ m* g; ?4 T7 ]7 f - RewriteCond %{QUERY_STRING} ^(.*)$
1 n h- V* l8 `0 _& \ - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1% i* c$ K% J+ q$ e$ @7 H
- RewriteCond %{QUERY_STRING} ^(.*)$
5 m1 E4 k2 f4 z g& `: E4 j7 W# e - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
3 L! @& x, |8 ^0 t" I* s2 } - RewriteCond %{QUERY_STRING} ^(.*)$9 h* l) W! M1 B; `+ S- N5 _- T
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1: M8 [; l* M: T' P1 l; b6 B8 }
- RewriteCond %{QUERY_STRING} ^(.*)$; J; J! N" `& h! i
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%13 J$ S C: S6 L/ k$ l- g) B/ E( A
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有
) k# K( Z1 Z) G$ }$ RLoadModule rewrite_module modules/mod_rewrite.so 這一行
" e+ ~8 d k# y) q6 u6 t然後重啟 httpd ==> service httpd restart* d( H6 T3 ?9 u/ v; O2 l
' t( ^- a2 J. ^' ?) t" U4 Q [. W5 N) h( r9 l
|
|