52AV手機A片王|52AV.ONE

標題: Apache環境設定偽靜態(rewrite)之SEO [打印本頁]

作者: IT_man    時間: 2016-8-14 11:43
標題: Apache環境設定偽靜態(rewrite)之SEO
本帖最後由 IT_man 於 2016-8-14 21:30 編輯
$ ^* u+ f- J! g, J$ ~" R- e
3 n7 t8 Y8 ^* m方法有二:
7 w; U2 b! j# F9 t8 U! K, i- f方法一〗使用.htaccess% Q) ^$ |& ]2 a+ N* ]" b* m
1.開啟網站根目錄之.htaccess(例如/home/test/public_html)
: ~6 k5 B* c. H" y
  1. RewriteEngine On
    % E( \- {, R6 z! o7 \# L/ S" W" U/ h
  2. RewriteBase /
    9 u! l, ~7 X% E, `& b
  3. 6 d* D* U7 P( a. ~: \# |; I
  4. RewriteCond %{QUERY_STRING} ^(.*)$
    - k6 f6 f8 s# ^4 ~1 H" L- J
  5. RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1
    , y# u% N$ t5 E% w2 @' i% v
  6. RewriteCond %{QUERY_STRING} ^(.*)$. x! ]- r/ E+ ~$ p* D
  7. RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1- u* K. |* x' b8 }/ q" V' h
  8. RewriteCond %{QUERY_STRING} ^(.*)$& v9 f+ A7 M4 j) h% `
  9. RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1- t& l( f& X" w" P4 k# o
  10. RewriteCond %{QUERY_STRING} ^(.*)$
    , @/ N& `4 _4 w
  11. RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%13 G4 B3 G1 G+ x, d
  12. RewriteCond %{QUERY_STRING} ^(.*)$
    . O' s, M( s4 L1 @. k1 R
  13. RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1! L- E0 r3 U# [6 ]
  14. RewriteCond %{QUERY_STRING} ^(.*)$& h) q' d" ?5 `, J: v- E% l
  15. RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
    : S2 w9 [& ^" F# L8 m5 F
  16. RewriteCond %{QUERY_STRING} ^(.*)$
    + T: E. o) B" s+ I
  17. RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
    % M7 y7 M' d, P9 Y( Z& \0 [
  18. RewriteCond %{QUERY_STRING} ^(.*)$' Y: Q1 Q9 f; [
  19. RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1+ A- Q# a2 u& Q6 z& h, V( e
複製代碼
2.Discuz3.2論壇後台->全局->SEO設置->URL靜態化->勾選所有靜態化 , 立即生效
6 z* ?2 i! E- a8 P方法二〗使用Apache的rewrite(mod_rewrite)設定" s4 c) Z0 p/ J( _# R
1.在/etc/httpd/conf/httpd.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內,或& {4 p+ F& M$ Z# Q
在/etc/httpd/conf.d/虛擬主機設定檔如virtual.conf內之<VirtualHost *:80>內的<Directory "/home/domain/public_html">內' f; ~. C( e- l
增加以下內容:
; ]# _' ?( M, F6 K8 C
5 ?" b" ~) Z* l9 F1 w* r" h
  1.     RewriteEngine On
    , `  T. s) H4 G7 M
  2.     RewriteCond %{QUERY_STRING} ^(.*)$& ]( S) M9 K- Q- H
  3.     RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topicid=$1&%1: \: ]* b* I6 [7 W6 E
  4.     RewriteCond %{QUERY_STRING} ^(.*)$
    9 \. ]. t- Q6 o9 E: ~
  5.     RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%13 o0 E1 E0 B+ U0 b5 D, {: {
  6.     RewriteCond %{QUERY_STRING} ^(.*)$1 z: ~& c6 x& T4 {1 `( N* [
  7.     RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1* Q' s; }/ |4 {2 K" A, P
  8.     RewriteCond %{QUERY_STRING} ^(.*)$$ y2 @/ p3 n: e7 |
  9.     RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1) g, b6 }" }% n; `9 p2 H1 Z: G# L
  10.     RewriteCond %{QUERY_STRING} ^(.*)$
    & s5 h8 g/ Z3 r" @8 J
  11.     RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1+ D+ j5 m/ O* _0 I; t) C3 [
  12.     RewriteCond %{QUERY_STRING} ^(.*)$. o8 g! @, O6 C+ E1 F
  13.     RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
    5 X- c. ~+ z9 _- c% Z
  14.     RewriteCond %{QUERY_STRING} ^(.*)$
    3 z, a  S5 @1 |$ ?! ?2 L. D
  15.     RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1! P& k# t0 O7 T6 s% s8 P0 ]6 f
  16.     RewriteCond %{QUERY_STRING} ^(.*)$- Y" R) x- S# ?/ V
  17.     RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
    9 n; A0 m/ b. }4 e$ K: H
複製代碼
2.在/etc/httpd/conf/httpd.conf內需有0 k; O2 Z  |2 A0 K$ Z3 o- G
LoadModule rewrite_module modules/mod_rewrite.so   這一行
# n5 L- |$ s+ V然後重啟 httpd ==>  service httpd restart
( j3 p( F4 ]5 B( }9 I% {3 ~5 l& }( b* k" Z1 E) l
% C% l; M) i6 _1 I) E( ~7 b0 l, j/ s





歡迎光臨 52AV手機A片王|52AV.ONE (https://www.52av.one/) Powered by Discuz! X3.2