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 v5 X# ^: Q% F" H+ W6 t
方法有二:) [3 R% P- ?: v0 L1 a- k
方法一〗使用.htaccess5 I) G% V& ?( c0 L8 o4 `$ F
1.開啟網站根目錄之.htaccess(例如/home/test/public_html)5 I! Y" @  _3 X7 O% O; E
  1. RewriteEngine On
    / W: o: m3 C6 p& ^" {0 [
  2. RewriteBase /
    1 d( k2 p7 ?' r/ K/ R  o
  3. 4 u& {0 A4 t" I4 n
  4. RewriteCond %{QUERY_STRING} ^(.*)$
    ' Z, l1 U4 k7 @& v; f9 ~
  5. RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
    2 y. l) j' }$ b: ?5 a
  6. RewriteCond %{QUERY_STRING} ^(.*)$; R: l) l$ Q  h! \5 _! v
  7. RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%15 ^7 y/ U& Y. r  v# U9 h5 x
  8. RewriteCond %{QUERY_STRING} ^(.*)$! Y9 x" P, o# R  ^
  9. RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
    2 a4 i2 ]) m! W. Y4 A3 |: M
  10. RewriteCond %{QUERY_STRING} ^(.*)$
    ; j3 u5 `) r! a( I
  11. RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%18 |% C5 J) N& e- Q  x1 U# l
  12. RewriteCond %{QUERY_STRING} ^(.*)$1 A+ Q7 j$ q2 _7 N! y8 ?' m, k3 _. S' N
  13. RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%14 f$ k5 R5 e& M5 u
  14. RewriteCond %{QUERY_STRING} ^(.*)$
    2 D( `3 u+ [% q& R& V* J
  15. RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
    - ]6 t2 t8 |* u7 M! S1 i
  16. RewriteCond %{QUERY_STRING} ^(.*)$* t9 }: g& Z0 W) D2 r7 |
  17. 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
  18. RewriteCond %{QUERY_STRING} ^(.*)$
    : a* n( T) `0 G! ^; b
  19. 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
  1.     RewriteEngine On2 a, S; B% d" u$ {% W! _$ L. k
  2.     RewriteCond %{QUERY_STRING} ^(.*)$
    ( {$ V: B% `3 r) Z- X
  3.     RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1$ p. \5 D0 T0 D( D. s
  4.     RewriteCond %{QUERY_STRING} ^(.*)$9 K5 p! i% i) k, E) u$ g3 c
  5.     RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1! \- v( X( h8 @; H
  6.     RewriteCond %{QUERY_STRING} ^(.*)$
    2 V" D7 _% ~% G7 ]1 A
  7.     RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%14 w; h$ \7 b- B5 C# ?  z& H# S
  8.     RewriteCond %{QUERY_STRING} ^(.*)$5 o0 }% o9 J$ R& o/ {
  9.     RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%18 }" D2 v5 q- y8 S. U  N2 s. m
  10.     RewriteCond %{QUERY_STRING} ^(.*)$4 B( w  q0 ^) V. E! D
  11.     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
  12.     RewriteCond %{QUERY_STRING} ^(.*)$
    : O+ Z1 Q/ [5 ?; z5 G* @3 V9 ?7 p" ]6 d0 U
  13.     RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
    / m; B5 ^' S8 r4 D  }: J0 k& [
  14.     RewriteCond %{QUERY_STRING} ^(.*)$
    6 e. t, J7 K6 `0 k& U0 }7 p7 @7 D
  15.     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
  16.     RewriteCond %{QUERY_STRING} ^(.*)$
    4 c) I  @8 E, v
  17.     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