tid=45014& 本帖最後由 IT_man 於 2016-8-14 21:30 編輯 + T b5 S' z9 I5 T
% H& q# S; j* Z) i3 u8 S
方法有二:
7 ^: i. v. W. ~0 t( t% u2 B7 |〖方法一〗使用.htaccess
- _, `2 [$ ~8 W1.開啟網站根目錄之.htaccess(例如/home/test/public_html)
4 x6 U$ `* s; G) \5 \1 a- RewriteEngine On3 ?' X% m" _( ?) c
- RewriteBase /. e2 U% ~8 h1 A5 ?) v& p8 D
- 6 h5 @( X7 x' F/ `2 L9 x
- RewriteCond %{QUERY_STRING} ^(.*)$7 c( z* Z0 E8 q
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
( Q/ y* Q0 J. J' b/ E3 ?& x" X - RewriteCond %{QUERY_STRING} ^(.*)$# n8 Y; x& U% B
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1; N7 V E6 R% Y& w
- RewriteCond %{QUERY_STRING} ^(.*)$9 T" E5 |2 t1 E, y# x. A5 O" i
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1' T. }6 {" Q# m6 M4 N( H
- RewriteCond %{QUERY_STRING} ^(.*)$3 Z0 a; Z2 q- k/ v9 P
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1: e& R% X1 Q7 J# K( h9 ]
- RewriteCond %{QUERY_STRING} ^(.*)$: a" ?1 [3 F9 z$ I3 O
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1+ Z6 q; c- `, |" c3 w a
- RewriteCond %{QUERY_STRING} ^(.*)$
5 S: {/ B: L+ W8 ], O; m, R4 C - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%14 Y& K; A, X/ T/ g
- RewriteCond %{QUERY_STRING} ^(.*)$
% l' R( p: z. i - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%10 e( g. m$ ?& L, |' g
- RewriteCond %{QUERY_STRING} ^(.*)$' D) Z! p6 n! l
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
5 k* j, q* r* R+ l
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
9 d, r7 [: y) H( A& D2 l O〖方法二〗使用Apache的rewrite(mod_rewrite)設定8 ]( Q3 Y: Y l
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或( m* o+ @: a: z5 z7 F* [7 J' g
在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內6 w7 n/ Y- h6 w$ J
增加以下內容:/ b) |7 b# `& u* p' e7 l5 t
c' G; F- D+ `8 G' [" [
- RewriteEngine On
' ^3 J! T) j; Q" O7 q1 j - RewriteCond %{QUERY_STRING} ^(.*)$' M+ I( n2 d. E, P' o# N. d* C, g4 E
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1# Q' o5 t5 u( }1 Z/ X a5 x) y
- RewriteCond %{QUERY_STRING} ^(.*)$
: L7 `+ [& K, z" m' s; a ~* G. o4 _ - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1" T! T# i5 p4 Y) b$ V
- RewriteCond %{QUERY_STRING} ^(.*)$- m. \7 g. g- A# z% \; k" p4 m" u$ W
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
' k `& }1 |- ~+ N' C7 ? - RewriteCond %{QUERY_STRING} ^(.*)$8 C0 F: T5 I. \# M x
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
: u7 ?# d, Z: V) ? - RewriteCond %{QUERY_STRING} ^(.*)$
3 N1 I* J: |2 E; @ - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
! B7 [2 `0 K! Q2 _+ o' B6 [4 W* y - RewriteCond %{QUERY_STRING} ^(.*)$3 C" x0 o+ M" ~4 [9 y6 c
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1% B- {, r) w0 k( S
- RewriteCond %{QUERY_STRING} ^(.*)$
b7 o. b0 v8 f! c* B9 t( \) T - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1 N# q/ A; s1 f/ m/ y" t
- RewriteCond %{QUERY_STRING} ^(.*)$
1 {: M0 y' ^% b" _ - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1 V" m, t8 C) n
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有1 b$ U% h5 a8 M% _# }. r
LoadModule rewrite_module modules/mod_rewrite.so 這一行
2 s5 q/ l9 `1 c5 x L# O4 N+ Q然後重啟 httpd ==> service httpd restart
% T( J/ Z" z1 a) T7 L# E7 x2 r
: l Q8 k+ M; f
- {* L0 \/ A- j/ G6 k |