52AV手機A片王|52AV.ONE
標題:
Apache環境設定偽靜態(rewrite)之SEO
[打印本頁]
作者:
IT_man
時間:
2016-8-14 11:43
標題:
Apache環境設定偽靜態(rewrite)之SEO
本帖最後由 IT_man 於 2016-8-14 21:30 編輯
; o; o4 A l2 q* ?) N1 f" Y% u1 o2 o
3 O. i+ Q' f) D+ x0 m9 d( n/ `
方法有二:
" @) B+ r( `+ k0 {8 l- q
〖
方法一
〗使用.htaccess
/ k* o7 g4 q# y' t# R9 f- O
1.
開啟網站根目錄之.htaccess(例如/home/test/public_html)
: s5 S( N* B; P# Y2 _" j
RewriteEngine On
& }2 Y( G! b1 R: B
RewriteBase /
( \) M8 \+ @5 E* R% b
x- ]6 E( z% x( y" ~8 X
RewriteCond %{QUERY_STRING} ^(.*)$
, i" V. J6 H; c: y0 r2 ]& M R
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
" v; i D Z$ ^7 M$ }& d' c1 q. V
RewriteCond %{QUERY_STRING} ^(.*)$
, r3 L% B! Z* M/ |6 S7 z! u
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
) S) h1 p9 ]( k
RewriteCond %{QUERY_STRING} ^(.*)$
3 E- o- v! ?& [( H! L6 c2 v. e( e* }
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
l& G8 ]( F0 t& O
RewriteCond %{QUERY_STRING} ^(.*)$
* j+ {2 @; ^! Z3 }; [9 L) z
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
. G8 L; q2 E; ~% T9 ^1 }
RewriteCond %{QUERY_STRING} ^(.*)$
7 z1 T z" y- i7 j9 j
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
3 g2 `2 D; x" ]1 _3 o2 S/ i
RewriteCond %{QUERY_STRING} ^(.*)$
q" c8 _6 a0 ]! Q; d7 H( C
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
5 g. m1 U: _4 e: a5 V: t7 [, ?
RewriteCond %{QUERY_STRING} ^(.*)$
, U* `/ w0 m+ T( U( @+ m0 O
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
% B C6 A0 f$ v- {
RewriteCond %{QUERY_STRING} ^(.*)$
* o9 [* m- |- w- e2 S
RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
1 E! w% x5 u& {8 A/ B
複製代碼
2.
Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
" Y$ U& N; v! K
〖
方法二
〗使用Apache的rewrite(mod_rewrite)設定
! K7 ]% \( j. N" _! u6 ^3 ^0 H
1.
在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
^1 _% N3 C; G$ ^4 ~
在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內
; Z7 g. s$ N S# G
增加以下內容:
$ j1 K- f6 U6 V: x% [8 Z% I
5 s0 P3 _: M9 P
RewriteEngine On
, M* o% V9 _' V* K7 |
RewriteCond %{QUERY_STRING} ^(.*)$
+ L Y' G2 U' G2 A7 B5 W) S
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
l, m& F: R: V+ G# M7 f
RewriteCond %{QUERY_STRING} ^(.*)$
6 q/ ^" B0 e4 e2 y$ A0 Z
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
4 [, i+ q! |# e& K* V; x
RewriteCond %{QUERY_STRING} ^(.*)$
% T w2 s0 L3 H$ ~$ Q& n
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
: w D5 G. q/ Q) b7 P7 ?
RewriteCond %{QUERY_STRING} ^(.*)$
' K' y3 `5 d2 g7 Z4 x X% [
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
8 }8 T( I- L0 d1 ^
RewriteCond %{QUERY_STRING} ^(.*)$
2 F% z/ E+ `: E7 X8 f
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
% `2 O4 b/ L) R2 [
RewriteCond %{QUERY_STRING} ^(.*)$
* @! f1 c7 n% V+ z
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
# i# f0 @; b! I1 J
RewriteCond %{QUERY_STRING} ^(.*)$
% Y2 ~6 R, F- r# `
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
" G' E6 e2 S9 \/ y3 L
RewriteCond %{QUERY_STRING} ^(.*)$
1 f' G% a0 t7 |! {! _3 N9 W$ S; b
RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
# M& s4 A0 l1 u: P% D
複製代碼
2.
在/etc/httpd/conf/httpd.conf內需有
+ X; L& m3 D+ J) m* @6 L
LoadModule rewrite_module modules/mod_rewrite.so 這一行
2 Z* X" Y: Q2 t2 M b# \
然後重啟 httpd ==> service httpd restart
& n3 S4 e# J6 O0 }% y. N* M5 |
) h7 g) M# h& F# c- N' A f. q
x( ~6 _$ s; q. M. c5 P0 n
歡迎光臨 52AV手機A片王|52AV.ONE (https://www.itech.casa/)
Powered by Discuz! X3.2