tid=45014& 本帖最後由 IT_man 於 2016-8-14 21:30 編輯
% Z p2 W) F, [6 L# X; I
4 n* y$ g; ?% V方法有二:1 @% H1 i- P( j; S, _
〖方法一〗使用.htaccess/ |% q+ p( g ]/ P1 j; ^
1.開啟網站根目錄之.htaccess(例如/home/test/public_html). i. O$ j3 _) c' c% u
- RewriteEngine On
( v& g( e' O& J A& y/ |1 B - RewriteBase /
y" J0 H% L0 |' ~3 A8 n. C. M
( c* R: r9 l! H/ m) Z/ S8 I$ F- RewriteCond %{QUERY_STRING} ^(.*)$/ k3 }1 P! l( e6 c- P
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%11 I8 K+ B) c9 E( l) K# Y: e7 R
- RewriteCond %{QUERY_STRING} ^(.*)$
/ D4 D. n* I" y, | - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1( `! Z9 K: |. g+ O% G4 {# ~
- RewriteCond %{QUERY_STRING} ^(.*)$0 y2 j- u1 n9 G! t, c
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
8 {4 `5 T+ N7 L) o C. Z1 k; ? - RewriteCond %{QUERY_STRING} ^(.*)$! J/ W5 z: n$ M2 u/ E
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1; [& N4 T9 ~- b- }! l0 f
- RewriteCond %{QUERY_STRING} ^(.*)$, M8 Q9 t% h6 |9 z2 M7 E' L
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1% v3 N1 Y- T0 F# l8 _* d, }& Q
- RewriteCond %{QUERY_STRING} ^(.*)$ L. U5 @( o; B; Y& J* C; f
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
: y4 k" [* F. z/ {( V/ N9 k+ O - RewriteCond %{QUERY_STRING} ^(.*)$
" d1 n2 N+ E2 M+ Y0 ?5 x - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%19 c: l* Z* L$ N1 \, z
- RewriteCond %{QUERY_STRING} ^(.*)$
_4 Q9 K9 q: N) m. P" Y& b - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1' @( l' R" L+ h, K' R0 z @4 Y
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
6 V; Y' D2 n2 W1 q/ w5 V) h" g〖方法二〗使用Apache的rewrite(mod_rewrite)設定 j, S3 U/ w0 R
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
0 ]: _- K9 f# A. ^1 e. z& K5 R- t在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內
/ }0 q' H0 A; F) J* j5 Y8 {( `增加以下內容:9 Z) j. }- x8 S; r# V% w4 d
$ a8 z" c& C: a& k" _- RewriteEngine On2 j1 Y- o v0 }4 r- M8 R; Y
- RewriteCond %{QUERY_STRING} ^(.*)$
& |/ ?: j' C) r# a - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
" C1 z9 m: T$ I) U7 }$ z, g8 ~9 i0 u - RewriteCond %{QUERY_STRING} ^(.*)$
! P1 s8 D) o$ G6 r# }3 Q' w5 D1 i - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
* X% c6 c! B8 w, I. o5 k - RewriteCond %{QUERY_STRING} ^(.*)$; ?4 k, f# J$ c
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1- {. _3 X$ a9 K+ g! [6 H" t
- RewriteCond %{QUERY_STRING} ^(.*)$9 N, g. W y! ~% N: h* y( E
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%16 U, Z1 B1 U' H/ B
- RewriteCond %{QUERY_STRING} ^(.*)$4 |* J; X" H3 q/ d/ A
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
* ?8 U: r, D- l$ y( Q$ O2 j# c" h - RewriteCond %{QUERY_STRING} ^(.*)$
) d+ H! q. O; l/ u - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1" r, q; Y2 W# f/ j) X% F3 P% x
- RewriteCond %{QUERY_STRING} ^(.*)$+ ~- \+ X& }/ Z+ c+ J, K
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1- p) E7 ]( ~0 j3 K4 @
- RewriteCond %{QUERY_STRING} ^(.*)$
& S, W$ ` u7 R& Z; ?( x - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
: q) Z" e# W+ U- ^
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有# }$ ]8 c+ X8 E# a4 X; }
LoadModule rewrite_module modules/mod_rewrite.so 這一行
$ S0 t" u t; g然後重啟 httpd ==> service httpd restart3 ^6 w9 D( r' ]( J8 w
7 r$ f" [1 b% B% @/ P q4 w: Y
% _ H! |. V% D: ~ |