52AV手機A片王|52AV.ONE
標題:
Apache環境設定偽靜態(rewrite)之SEO
[打印本頁]
作者:
IT_man
時間:
2016-8-14 11:43
標題:
Apache環境設定偽靜態(rewrite)之SEO
本帖最後由 IT_man 於 2016-8-14 21:30 編輯
( a! }) z3 H# |6 c7 j4 ?+ o: f
) d. [& P$ ?; k: @( `3 S2 N5 a& i
方法有二:
+ ]* A n& z- l
〖
方法一
〗使用.htaccess
5 p% C5 ~4 x, H
1.
開啟網站根目錄之.htaccess(例如/home/test/public_html)
6 ? w) X) j2 n2 W2 n
RewriteEngine On
" V% t, G3 u( H# f. \& q7 ]
RewriteBase /
+ i& D; A5 |- @& {/ P, z1 z
2 `+ f* j% e7 B2 ~5 {: S- N
RewriteCond %{QUERY_STRING} ^(.*)$
, h1 H8 F% u' W- A7 D( T+ `% q+ H: I
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
4 a4 }( A% U) Z& c* u6 M
RewriteCond %{QUERY_STRING} ^(.*)$
4 M3 X, m! N& h! T2 w2 g+ c8 a
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
' ]1 g, F% k# i6 x6 e
RewriteCond %{QUERY_STRING} ^(.*)$
$ F( c0 i3 \4 {3 d% t
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
2 n# i6 W* [+ Q2 |
RewriteCond %{QUERY_STRING} ^(.*)$
% }! g0 c: d u- U, W7 E0 D
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
0 v. b+ m0 e/ Q: g
RewriteCond %{QUERY_STRING} ^(.*)$
2 c; n/ [3 z/ I1 r L: T/ m
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
! `: \+ y7 w$ W
RewriteCond %{QUERY_STRING} ^(.*)$
1 s" Y) j& v5 M
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
# T5 {# B- H. L( r) p
RewriteCond %{QUERY_STRING} ^(.*)$
2 Q( T+ u6 ^& R1 h7 F2 l
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
~; k$ c2 D5 G* Y" k/ o
RewriteCond %{QUERY_STRING} ^(.*)$
. u i6 O; S% X
RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
; R* Z1 @1 q4 r( K6 X; k; b% G+ U
複製代碼
2.
Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
* _- h, a5 V8 e6 k
〖
方法二
〗使用Apache的rewrite(mod_rewrite)設定
& Y5 q) _+ S0 A: \
1.
在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
Z! |' g: V6 {2 T
在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內
* N) v$ Q9 p) Y+ {. y- b, h. {9 o# M. Q
增加以下內容:
7 a e& `! d! A- `0 x9 b9 e% Z7 \9 D
. \* P) |# V5 h5 v2 D
RewriteEngine On
0 G) J& U5 y0 |
RewriteCond %{QUERY_STRING} ^(.*)$
5 E3 q& ]1 u% g" w+ p
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
: J! ]; R5 E3 A; y
RewriteCond %{QUERY_STRING} ^(.*)$
l* y- w( N$ \6 p9 i
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
, S& u+ S1 O8 K0 @8 h9 V3 S% [
RewriteCond %{QUERY_STRING} ^(.*)$
# ~! `: E9 G: I1 Y
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
4 J4 n f7 E8 u) b! I
RewriteCond %{QUERY_STRING} ^(.*)$
0 v9 \% `. i; s/ h$ j: Z
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
8 j/ Z+ ]8 |0 \9 @
RewriteCond %{QUERY_STRING} ^(.*)$
5 c& O/ Z* c$ f
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
% D4 S3 y! j, K8 p& @
RewriteCond %{QUERY_STRING} ^(.*)$
8 ^+ P& j0 t, H! b7 g9 n$ {
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
9 @5 j4 B+ b" z" F0 \& d( O
RewriteCond %{QUERY_STRING} ^(.*)$
: T- U9 V9 M8 d7 s0 N
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
" a! Y, T2 t' Z. ~ l8 p: p
RewriteCond %{QUERY_STRING} ^(.*)$
7 _ }5 }; _; a* Z: L0 w
RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
, N+ t4 J2 A! ^& q! E* Y
複製代碼
2.
在/etc/httpd/conf/httpd.conf內需有
# p+ ^7 j. [1 e; R* s3 K
LoadModule rewrite_module modules/mod_rewrite.so 這一行
+ J, A# Y: q) K% r9 a- m' v
然後重啟 httpd ==> service httpd restart
: G! y- ?3 Z ]" [( V+ x9 F
- Q# B; Z7 ?# }0 l
' M$ D( l9 W' b1 }! Y* R* z j
歡迎光臨 52AV手機A片王|52AV.ONE (https://nhkie.com/)
Powered by Discuz! X3.2