本帖最後由 IT_man 於 2016-8-14 21:30 編輯
3 k% q' B) v1 ~8 J, Y
( i4 y7 H5 _) n方法有二:
6 _* t% Z5 }% `) t$ {- A〖方法一〗使用.htaccess
8 g5 D. }; I; q( \1 F [1.開啟網站根目錄之.htaccess(例如/home/test/public_html)" W4 x( B1 S5 n" Z
- RewriteEngine On( ]; t* y1 k2 l' Z
- RewriteBase /, W) F" u2 `/ v8 Z0 H: e
- ' Q. n) c$ [1 F4 D
- RewriteCond %{QUERY_STRING} ^(.*)$7 k" k$ l ]: C+ \
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
1 ` x, V, E) e - RewriteCond %{QUERY_STRING} ^(.*)$
, K/ `6 V& t4 F5 @& e - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%12 q0 Q( _7 q' a `
- RewriteCond %{QUERY_STRING} ^(.*)$
* o9 i$ i. Z% P6 E - RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
. O( M+ y, N) p# g' _( F - RewriteCond %{QUERY_STRING} ^(.*)$
' ~6 @% X9 M1 F - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
* r _4 Y/ ?, ?! A - RewriteCond %{QUERY_STRING} ^(.*)$
/ _" i& ?1 ^; r8 f - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
; M/ w4 `3 N6 {# u+ ` - RewriteCond %{QUERY_STRING} ^(.*)$1 G d8 S3 e% K; |, N
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
+ x7 y1 F( a& n3 q! X9 S) E - RewriteCond %{QUERY_STRING} ^(.*)$
% S1 ~2 \) o! q+ X - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
+ F; ?9 q: X# l4 v& Q( @: r; A) u - RewriteCond %{QUERY_STRING} ^(.*)$& V8 K3 \1 K* e5 ^( e
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
% w* ~. j, h2 W F' ?1 ~: O
複製代碼 2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
2 N# W" J r- K; N. R〖方法二〗使用Apache的rewrite(mod_rewrite)設定7 B# ^$ d6 q1 g o
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或. J: f+ I2 z8 _: ^
在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內6 `" J" @( j6 e7 u& B
增加以下內容:
- N8 Z$ A+ x! {1 w' U1 N! Q; ?, g$ |1 Z# A% A
- RewriteEngine On) _. q( F; [/ O+ l: U
- RewriteCond %{QUERY_STRING} ^(.*)$
) n( B- p; r, U- x8 w - RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
& L& W. Q( i# H, V9 Q - RewriteCond %{QUERY_STRING} ^(.*)$
- X" d6 Q7 Q" t* }& Y& ` - RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%15 u0 k1 `( z+ J; Z0 M
- RewriteCond %{QUERY_STRING} ^(.*)$6 Z( }. M! }( F. r$ O; Y
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
1 g0 Y# ~" ~- A V+ P! f - RewriteCond %{QUERY_STRING} ^(.*)$
3 `8 Z$ R6 X1 P8 `5 [; y - RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1& ^' F2 C6 {4 C# _5 I
- RewriteCond %{QUERY_STRING} ^(.*)$
% @7 a& e5 U8 X3 A" i9 _4 {, G' I - RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
+ K+ Z6 {7 i+ R: X - RewriteCond %{QUERY_STRING} ^(.*)$
' K8 a2 o: |8 p p! H - RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
4 I+ ~. Y1 R- V" Z - RewriteCond %{QUERY_STRING} ^(.*)$
$ p6 t: w1 U8 ?% U% L - RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1( D5 P6 `3 K% U* L
- RewriteCond %{QUERY_STRING} ^(.*)$0 j: X6 d5 h+ r. X
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
" {* N e( g8 ?
複製代碼 2.在/etc/httpd/conf/httpd.conf內需有. o+ @- s' n D7 r
LoadModule rewrite_module modules/mod_rewrite.so 這一行 t: m k; z; L0 O! A+ V
然後重啟 httpd ==> service httpd restart
C# s |. K2 [2 k$ [
& b0 s) h9 n9 d) {4 H
$ S0 y* ?/ |+ C7 k& f" d* { |
|