tid=45014& 本帖最後由 IT_man 於 2016-8-14 21:30 編輯
% \ `7 ~! T/ t! V# A- i- N0 m$ u) l7 P9 I
方法有二:6 }% E U8 W; C9 B: Y
〖方法一〗使用.htaccess
, X8 m* b4 \6 A X1.開啟網站根目錄之.htaccess(例如/home/test/public_html)8 F6 O: R% U+ z0 H7 @# a
- RewriteEngine On" Z: i1 k! y/ U2 D8 f
- RewriteBase /
A5 p$ W8 W0 }/ ^ - . X" b2 N* F" m, Q: Y! u" D) ]
- RewriteCond %{QUERY_STRING} ^(.*)$2 ]- M2 B4 p. x A9 ~% t# v8 ]
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1" X- `$ U9 k0 [: P4 s9 l
- RewriteCond %{QUERY_STRING} ^(.*)$
" Y3 V& b# a$ H1 l - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1; ^- i! ^. ]5 y; P7 \4 f, B
- RewriteCond %{QUERY_STRING} ^(.*)$+ G4 \: N; h, K/ \8 \% L/ H9 R
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1+ J( H2 F; t3 q! m
- RewriteCond %{QUERY_STRING} ^(.*)$
* S7 ?* y' J+ \* `$ [7 a - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1( ]. u+ `/ R2 T$ C. E
- RewriteCond %{QUERY_STRING} ^(.*)$! A1 I6 I& x4 N( A9 Y
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
8 E7 [0 B" Y9 j8 \6 r+ x/ ~ - RewriteCond %{QUERY_STRING} ^(.*)$$ p( q8 |+ r! _! d- g2 d0 x
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%16 s8 C6 e$ ?2 `4 Y
- RewriteCond %{QUERY_STRING} ^(.*)$
: [3 t5 q c. [3 z; i - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1/ ]. q M; Q3 }# ~* b' k
- RewriteCond %{QUERY_STRING} ^(.*)$1 x3 r( ^" F( Y
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
( T6 H" [( W1 ]# R
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效 W% k; Q4 X7 b2 D- S( R
〖方法二〗使用Apache的rewrite(mod_rewrite)設定, B, \) g5 V1 K5 h( U
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或1 g0 O/ b/ z2 r3 J/ N; [
在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內1 X `; u; T2 k- c
增加以下內容:8 C S. u+ h+ [) z6 a4 F7 m/ i+ ]! ~
2 }% E: P& d Q1 v0 L: M% H# C- RewriteEngine On
( u! s' V4 i3 I! P- i% F - RewriteCond %{QUERY_STRING} ^(.*)$
; R4 D/ @4 k# T - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1; T P# {: b+ e' M
- RewriteCond %{QUERY_STRING} ^(.*)$
3 g( q2 W0 u% y# o - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%13 F9 A! `, v2 S! t; o
- RewriteCond %{QUERY_STRING} ^(.*)$/ ^, n, B5 z( c- s! y7 \% M7 @0 a8 T
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
; M% r& B5 W% Y: a: E3 z h! E - RewriteCond %{QUERY_STRING} ^(.*)$. Y0 p' E% l& _( d( c" m5 \
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1# ?( Z# f4 M+ B$ f+ D9 A8 O" H0 y( }
- RewriteCond %{QUERY_STRING} ^(.*)$0 q; q4 d: Q1 m- N! h( b
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
8 w9 r7 u* v* t3 D) K" O% G- k - RewriteCond %{QUERY_STRING} ^(.*)$5 c6 d/ c7 d) d, N' A6 y
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1; U! F3 e, D* _9 q4 V' L: `% l
- RewriteCond %{QUERY_STRING} ^(.*)$- ]4 H; E$ \$ A( t9 f
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
/ @" D8 |+ W% c - RewriteCond %{QUERY_STRING} ^(.*)$
- `6 ~9 n! S: a0 [3 h - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
( F! x$ P$ R e6 m5 n
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有$ } Z e3 U4 m: h$ z
LoadModule rewrite_module modules/mod_rewrite.so 這一行& I: d4 N- l: e6 C2 `7 T3 w
然後重啟 httpd ==> service httpd restart: t6 J5 x$ ^& u5 q' o+ p1 l/ J+ \8 o
3 |! I( {, H1 u. c+ ^5 [
+ V# r U1 G0 A% Z4 |/ J% d* z8 Q J1 x8 e, q
|