tid=45014& 本帖最後由 IT_man 於 2016-8-14 21:30 編輯 ! [/ ~9 D/ y3 q1 C5 @7 o
0 q3 ^" x. S& m3 m
方法有二:
6 E$ B! @- _# T& ~/ l6 S8 L7 r〖方法一〗使用.htaccess
% |! t+ G# {+ `/ N1.開啟網站根目錄之.htaccess(例如/home/test/public_html)/ w! I& m. j; E! J3 _/ y1 K8 H
- RewriteEngine On
: b: H! V( {' c$ ]- k; y - RewriteBase /( `: p8 G4 W: a: c4 S# j" w
2 [# p0 w0 e# D, {* }9 G8 C- RewriteCond %{QUERY_STRING} ^(.*)$
0 \1 F) F+ F4 {. e" X5 S) o - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1 A# Y) }* s/ E1 p) q8 Q, I
- RewriteCond %{QUERY_STRING} ^(.*)$. R5 M# G5 u' V0 N: `$ f h
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1. Q+ I c4 o+ a1 o! n
- RewriteCond %{QUERY_STRING} ^(.*)$6 |6 j6 Q0 z- K* U
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
) ~: @3 P: F" \ - RewriteCond %{QUERY_STRING} ^(.*)$
7 u3 u+ j( K9 ?7 L/ o - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
0 R9 m7 \; P# a) n M - RewriteCond %{QUERY_STRING} ^(.*)$
: I" t5 z6 R- J - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
. F9 I- G' B; \( a y1 Q - RewriteCond %{QUERY_STRING} ^(.*)$
1 t4 D% Z/ I ~% o - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
! O& ~+ O k- q$ P - RewriteCond %{QUERY_STRING} ^(.*)$3 `$ I/ |: b1 ]3 x
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
4 J0 l/ O& Q3 l2 s - RewriteCond %{QUERY_STRING} ^(.*)$ _3 R+ i$ t" }: `6 ?, v
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
; ^* u" C, R9 ]( m; U; ^1 h) ^
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效6 E5 v7 h0 b' q- U& \% M
〖方法二〗使用Apache的rewrite(mod_rewrite)設定
S, h6 u3 i, r0 U4 C% N8 A1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或$ c, l) y/ t* g( g8 c7 k) z
在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內5 H2 f& U* w5 T1 W) e
增加以下內容:7 ]1 ^0 Q1 K, s1 Q( l
4 s; H$ l/ W7 v
- RewriteEngine On
+ i1 Y8 F; w! ^( p8 e' l - RewriteCond %{QUERY_STRING} ^(.*)$* Z, Y) m& y; y+ D- k
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
0 |! ?* K) {4 q/ m) s - RewriteCond %{QUERY_STRING} ^(.*)$
8 S* F7 W, q) S' C) [1 o1 F - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
- z( v( T8 g7 K/ u3 L' q - RewriteCond %{QUERY_STRING} ^(.*)$
d1 `6 H# s" b' l - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1/ ~' z3 R& S J! X) z: s& M6 l) m
- RewriteCond %{QUERY_STRING} ^(.*)$
2 N" d- ? u& D! c - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
! r2 r) t H. Z* `# h - RewriteCond %{QUERY_STRING} ^(.*)$2 H2 _* q$ O9 {! F
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1( Z0 }; g/ L$ x- ?
- RewriteCond %{QUERY_STRING} ^(.*)$
! p0 R6 ?1 f) \# y1 Y - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1% V. v+ e# W' l
- RewriteCond %{QUERY_STRING} ^(.*)$* a8 N1 T3 l. d! U( d# J
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1. [ Q* H/ g9 K! K5 v3 i
- RewriteCond %{QUERY_STRING} ^(.*)$
! D/ R4 G% \) d& b - RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1' E4 R8 U& `: X M8 G; W
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有4 E x+ [' l5 {
LoadModule rewrite_module modules/mod_rewrite.so 這一行
Y, j$ ]4 Z, b( w# V4 g0 h然後重啟 httpd ==> service httpd restart
( n) @2 l- U5 _8 k( \
5 n- c5 W3 S v H7 }- f$ a& W) c
' k8 C) P# J; @* p! }& J |