52AV手機A片王|52AV.ONE
標題:
Apache環境設定偽靜態(rewrite)之SEO
[打印本頁]
作者:
IT_man
時間:
2016-8-14 11:43
標題:
Apache環境設定偽靜態(rewrite)之SEO
本帖最後由 IT_man 於 2016-8-14 21:30 編輯
* C. H+ s$ p, K3 a3 _4 P) n) |3 W5 v
5 X# ^: Q% F" H+ W6 t
方法有二:
) [3 R% P- ?: v0 L1 a- k
〖
方法一
〗使用.htaccess
5 I) G% V& ?( c0 L8 o4 `$ F
1.
開啟網站根目錄之.htaccess(例如/home/test/public_html)
5 I! Y" @ _3 X7 O% O; E
RewriteEngine On
/ W: o: m3 C6 p& ^" {0 [
RewriteBase /
1 d( k2 p7 ?' r/ K/ R o
4 u& {0 A4 t" I4 n
RewriteCond %{QUERY_STRING} ^(.*)$
' Z, l1 U4 k7 @& v; f9 ~
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
2 y. l) j' }$ b: ?5 a
RewriteCond %{QUERY_STRING} ^(.*)$
; R: l) l$ Q h! \5 _! v
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
5 ^7 y/ U& Y. r v# U9 h5 x
RewriteCond %{QUERY_STRING} ^(.*)$
! Y9 x" P, o# R ^
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
2 a4 i2 ]) m! W. Y4 A3 |: M
RewriteCond %{QUERY_STRING} ^(.*)$
; j3 u5 `) r! a( I
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
8 |% C5 J) N& e- Q x1 U# l
RewriteCond %{QUERY_STRING} ^(.*)$
1 A+ Q7 j$ q2 _7 N! y8 ?' m, k3 _. S' N
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
4 f$ k5 R5 e& M5 u
RewriteCond %{QUERY_STRING} ^(.*)$
2 D( `3 u+ [% q& R& V* J
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
- ]6 t2 t8 |* u7 M! S1 i
RewriteCond %{QUERY_STRING} ^(.*)$
* t9 }: g& Z0 W) D2 r7 |
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
1 S% Y1 b5 \+ T; H, c6 e! u
RewriteCond %{QUERY_STRING} ^(.*)$
: a* n( T) `0 G! ^; b
RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
+ X/ c. R0 d x* t3 o! H% W
複製代碼
2.
Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
7 e9 E" r* @0 U) |
〖
方法二
〗使用Apache的rewrite(mod_rewrite)設定
/ U3 Y4 v* a! b3 q
1.
在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或
; k7 E0 k! v1 F' p) a$ [
在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內
g1 |& r# z5 n
增加以下內容:
" w+ k9 Z# x4 k
8 `& Z' y4 K3 k% ?2 @2 f3 d
RewriteEngine On
2 a, S; B% d" u$ {% W! _$ L. k
RewriteCond %{QUERY_STRING} ^(.*)$
( {$ V: B% `3 r) Z- X
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
$ p. \5 D0 T0 D( D. s
RewriteCond %{QUERY_STRING} ^(.*)$
9 K5 p! i% i) k, E) u$ g3 c
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
! \- v( X( h8 @; H
RewriteCond %{QUERY_STRING} ^(.*)$
2 V" D7 _% ~% G7 ]1 A
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
4 w; h$ \7 b- B5 C# ? z& H# S
RewriteCond %{QUERY_STRING} ^(.*)$
5 o0 }% o9 J$ R& o/ {
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
8 }" D2 v5 q- y8 S. U N2 s. m
RewriteCond %{QUERY_STRING} ^(.*)$
4 B( w q0 ^) V. E! D
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
! R: M) L8 @ C6 K6 W8 {; L6 Y+ S2 a
RewriteCond %{QUERY_STRING} ^(.*)$
: O+ Z1 Q/ [5 ?; z5 G* @3 V9 ?7 p" ]6 d0 U
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
/ m; B5 ^' S8 r4 D }: J0 k& [
RewriteCond %{QUERY_STRING} ^(.*)$
6 e. t, J7 K6 `0 k& U0 }7 p7 @7 D
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
6 t. v( i& t n# f; s
RewriteCond %{QUERY_STRING} ^(.*)$
4 c) I @8 E, v
RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
% X2 S! z* x+ e5 N9 [
複製代碼
2.
在/etc/httpd/conf/httpd.conf內需有
$ Q ~2 i' q1 y
LoadModule rewrite_module modules/mod_rewrite.so 這一行
5 `/ i5 b, F8 ^3 c4 |0 J
然後重啟 httpd ==> service httpd restart
5 p" ]( ], X7 `- i" i2 t
- o5 c. d- ~! s1 H! \( R7 B" _
9 n6 `, H1 L1 x
歡迎光臨 52AV手機A片王|52AV.ONE (https://www.52av.one/)
Powered by Discuz! X3.2