tid=45014& 本帖最後由 IT_man 於 2016-8-14 21:30 編輯
9 t3 y4 U1 G2 T' y5 W
+ q; _1 M" ~. e$ w$ M方法有二:
* j. Z% R' b3 Z. O7 h/ s* U7 r' `〖方法一〗使用.htaccess
% v7 H1 ~% r/ t' p; l# z! R. `1.開啟網站根目錄之.htaccess(例如/home/test/public_html)/ y7 n8 n& t* y5 v9 Y ^& x
- RewriteEngine On8 V, V% n. e7 ^
- RewriteBase /: R! \: z N, t8 ^9 O4 D
- # C4 X' h# a" }( {6 d: j( h
- RewriteCond %{QUERY_STRING} ^(.*)$% g& X S+ _+ K4 ^8 M! d( X
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1' m6 S4 Z, K9 m
- RewriteCond %{QUERY_STRING} ^(.*)$
& R8 v6 Y7 y' x4 x: y4 j. d - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%14 ~4 `3 ]9 j9 X3 D
- RewriteCond %{QUERY_STRING} ^(.*)$
3 H: e K# v3 [. g9 {) I - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
7 y4 ]4 F9 _% l0 e6 c - RewriteCond %{QUERY_STRING} ^(.*)$! }' s5 J+ f( K2 E' s6 d
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%13 R7 a# n4 N+ U2 L" {8 u
- RewriteCond %{QUERY_STRING} ^(.*)$# z, D; [* q& z T
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1" W1 a0 g1 ]7 X4 f, {' Z
- RewriteCond %{QUERY_STRING} ^(.*)$/ _- V; {6 K4 d. d2 p
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1) c- ^7 r$ M7 f, }
- RewriteCond %{QUERY_STRING} ^(.*)$ ]% p! t- X C9 F
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%19 N% ^8 y! T0 R9 k5 Q. }
- RewriteCond %{QUERY_STRING} ^(.*)$0 c) a$ q' `4 u6 G
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
! w* N) p9 b5 `, N- {' h
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
* D$ |& y" Q2 I) ?! a〖方法二〗使用Apache的rewrite(mod_rewrite)設定
. W- h/ [2 U! J1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
( F: j9 e. a5 x7 X- |& n在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內" b) A p( S8 r- [; ?& f/ }
增加以下內容:
' s" z$ L- S1 {6 D5 X
2 ~( l8 h5 c' m3 p1 [4 Q6 f- RewriteEngine On
, M, W3 {( `: m, t4 i( R - RewriteCond %{QUERY_STRING} ^(.*)$$ c# X) G+ g; b, p. |% ^
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
# y4 K/ `" X) Q* r( J+ A5 F - RewriteCond %{QUERY_STRING} ^(.*)$" \: V( V1 ?8 r
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%12 m5 k6 ^6 P1 t/ q( ^
- RewriteCond %{QUERY_STRING} ^(.*)$
/ @# ?6 I5 [& y, N - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
, O. e. a/ f$ u, g; Y# C - RewriteCond %{QUERY_STRING} ^(.*)$4 r5 R$ s, s3 w1 k
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
. h7 s l7 C5 s! Y3 V. i/ S K - RewriteCond %{QUERY_STRING} ^(.*)$3 h6 w) B! _. c7 y: u. }4 t
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
4 I% }* I5 W" J3 q - RewriteCond %{QUERY_STRING} ^(.*)$
2 g2 r# I9 H) e d7 P9 Z1 Q# } - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1+ n- Z4 A/ f7 c% I7 r X) U: L
- RewriteCond %{QUERY_STRING} ^(.*)$% h. O0 M4 p* F- l
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
$ t) m, k4 A6 k - RewriteCond %{QUERY_STRING} ^(.*)$6 f4 K2 m5 U! G
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
1 ~+ j% O* q3 V7 ]/ w
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有 y3 ?$ i2 h% I' S, ^1 z
LoadModule rewrite_module modules/mod_rewrite.so 這一行$ o* E2 p0 m9 a3 H
然後重啟 httpd ==> service httpd restart
7 E. d( o! W& w J8 b9 Y$ \# p" b8 N
, C1 l# B) I, c$ f
|