tid=45014& 本帖最後由 IT_man 於 2016-8-14 21:30 編輯
- T f* Q- V: V/ S9 z1 B0 t; N1 Q' A* `) U
方法有二:
6 ?4 ]0 \" ?" u1 X4 m〖方法一〗使用.htaccess
* M; {8 b, ?% l5 A1.開啟網站根目錄之.htaccess(例如/home/test/public_html)' B0 e( L6 p- f4 ^; i
- RewriteEngine On
; ~& T- C& k, S2 _: s v* T+ ] - RewriteBase /
! N# b7 e4 W" j1 W8 y$ r
4 V. | i3 y3 z' V8 |0 Z- RewriteCond %{QUERY_STRING} ^(.*)$
- V7 { B# u6 t9 D - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1; o/ Z- s4 U4 t
- RewriteCond %{QUERY_STRING} ^(.*)$
# Q a K$ r" J H S: n - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1" P, R2 O& t. t3 N2 Q
- RewriteCond %{QUERY_STRING} ^(.*)$
% n1 a* f# A& ?7 p( l - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
|: k7 a, Q+ H9 E - RewriteCond %{QUERY_STRING} ^(.*)$
) q/ I0 X8 S5 h1 ] - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
$ ^. n. v% u( V: y; I# d - RewriteCond %{QUERY_STRING} ^(.*)$
+ I# b: ?/ j$ R8 n, n - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
2 ~& A# s7 M3 t" t: W4 K - RewriteCond %{QUERY_STRING} ^(.*)$
1 q* P, V7 p; c9 R - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
! i3 m, h, ^7 H0 y3 B) R# Z - RewriteCond %{QUERY_STRING} ^(.*)$
, O* A+ Z0 m. v" r( p - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1+ L9 E( a5 v, a
- RewriteCond %{QUERY_STRING} ^(.*)$: d, {( n3 w i p5 q+ I6 K
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
9 Y3 f* f2 m1 \8 z3 R) k: J) j- I1 p
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
, j" h' w4 ~% o. y〖方法二〗使用Apache的rewrite(mod_rewrite)設定9 g0 e# E4 _. \# Z& j
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
+ O1 Q8 c, Q4 g在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內 \' B) p5 }- c9 x& e8 y6 ~ w
增加以下內容:
x( q5 Y2 Z9 @8 o$ ]7 M |2 b, u$ J, t9 @* ]3 }0 _
- RewriteEngine On
, {% ^4 E) S- H8 y/ {5 P - RewriteCond %{QUERY_STRING} ^(.*)$- a9 D2 b( P3 b$ F/ _. q+ W" N
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1. j5 @$ J" {) r1 F# A% }# L
- RewriteCond %{QUERY_STRING} ^(.*)$
7 w* l' q) b* ]0 N* G( H8 w - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
/ r8 z+ d( O% L: g4 a/ U - RewriteCond %{QUERY_STRING} ^(.*)$; D9 s& ]: w. d/ `! K0 `
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
! R( J6 ?2 Z1 q+ x - RewriteCond %{QUERY_STRING} ^(.*)$
$ w3 l% v$ j4 N- R. k - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
. y/ d. j# O* O$ s; \$ D5 W! Q - RewriteCond %{QUERY_STRING} ^(.*)$3 j8 l" T' H# Z/ p
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
! S4 z5 l( Y3 B3 M - RewriteCond %{QUERY_STRING} ^(.*)$
# E6 w/ U% p$ q0 f( x - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1# s- m y6 A6 m' M2 k/ c
- RewriteCond %{QUERY_STRING} ^(.*)$
' ^; }0 w; E$ \+ v% a: e0 b& V - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
0 }2 k. g& U/ H E8 Q; z - RewriteCond %{QUERY_STRING} ^(.*)$
+ E4 F" Z5 |( F6 s& P6 b - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1( A1 \2 H0 S5 P! a# A$ s' N
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有5 m& r X. W, |- ^- y
LoadModule rewrite_module modules/mod_rewrite.so 這一行9 s1 W- b# c# b4 u% ?
然後重啟 httpd ==> service httpd restart0 h1 D# y) A5 @, s3 Q
+ X8 r" c2 R: d7 A8 F% q/ r. V$ [) [
|