砍敺 IT_man 2014-12-24 18:42 蝺刻摩 % w# G9 n) X6 d5 N5 I" r
; @7 f5 u( x7 U
閮望潭蝬脩閬,銝餉舐箔SEO(search engine optimize) in discuz x3.2 敺->典->SEO閮剔蔭->URL(閮剖摮),google鈭銝鈭鞈,憒銝:! L4 y0 g+ B. ~; z% m+ L! I
隞蝝嫘
9 F1 C3 w* Y' w+ J% W' \URL Rewrite(URL撠)臭蝔娜EST (Representational State Transfer嚗銵典噩頧蝘)賊銵嚗摰臭誑 Web Server 銝哨撠雿輻刻靘 URL 脰頧敺嚗喳 Web Server 銝剔蝔撘具
: g" H% D- j8 \0 \3 ~! v雿輻刻臭誑雿輻刻渲死孵靘頛詨 URL嚗銋 REST 銝餉桃嚗嚗舀撠撘雿喳嚗SEO嚗雿瘜銋銝函撘潸臭誑拍券璈嗡撠賊梯韏瑚嚗舫踹霈蝬脰楝銝⊥雿輻刻園唳拇潛澆餅鞈閮
" M& o( X0 Q# L1 {7 g, ]2 \渡
1 \1 |: h! d) o* d! i0 x雿輻沖eWrite 閮剖嚗敺嫣噶啣臬祆胯http://www.av4u.info/forum.php?mod=viewthread&tid=192&extra=page%3D1璅撘URL嚗霈http://www.av4u.info/thread-192-1-1.html敶W 'URL1 K% s7 j0 a$ D: n
ReWrite臭誑甇閬銵函內撘靘銵券,潭迤閬銵函內撘隤瘜隢
1 x+ N% T$ I$ U& {; J/ Q雿輻 ReWrite 憟質鈭:
4 u; G" Z K# Q! N& E" DI.霈 URL 韏瑚瘥頛哨銝撣嗅貊 'URL' 敶W撠雿輻刻靘隤芣頛蝧嚗 R% g0 O% A* {+ B4 Y
II.拇 SEO嚗撠撘瘥頛憟賣0 w. M& e9 F$ p
Rewrite隤瘜
" E0 ]- E7 v- U0 @隞乩摮1隤芣:- RewriteEngine on
' c6 g8 k' \" i - RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5.0.*
6 E2 w' Z! e: T - RewriteRule index.php index.m.php; v' a& d7 Q0 k
- RewriteCond %{HTTP_USER_AGENT} ^Lynx.*
% r, X: D8 H% Q& G1 G% B - RewriteRule index.php index.L.php
0 I3 R9 N2 y* I( p9 o1 J - RewriteRule index.php index.b.php; I, P H7 O: M$ B [
銴鋆賭誨蝣 隤蝑:) [6 j( d3 z0 N7 x8 D, o
- if($_SERVER['HTTP_USER_AGENT'] == 'Mozilla/5.0) //FireFox閬賢- E! F, V9 Z: d) o: i8 a
- {
' s& r' {9 J! ]1 X6 P+ d" W - //頧迺ndex.m.php
5 V7 U2 b8 Z- d" L7 ` - }
8 R1 g4 [4 `" z4 @9 n# } - else if($_SERVER['HTTP_USER_AGENT'] == 'Lynx') //蝘餃閮剖閬賢& t8 @3 J) i' C! ?+ F* x0 T' r
- {
/ O- d1 E8 I1 H8 @! l+ H, N - //頧迺ndex.L.php
+ m5 H) U4 X! u7 s, O - }" t8 X9 h2 B- q2 I2 N( b, \7 T8 Y+ y4 E
- else //嗡祉閬賢
% Z6 \: s' f* W% x1 n% z) \( S - //頧迺ndex.b.php
銴鋆賭誨蝣 靘摮2.
! z3 Q5 p( L; C, T& @7 U M" I- n+ ~5 V- RewriteCond %{REMOTE_HOST} ^host1.* [OR]
* c8 C8 N! e- U% ?: U - RewriteCond %{REMOTE_HOST} ^host2.* [OR]! A; r" v) y/ q5 k3 \) J
- RewriteCond %{REMOTE_HOST} ^host3.*
- X+ v+ _2 \/ i, x1 F \& I - RewriteRule (.*)$ test.php
銴鋆賭誨蝣 憒啣疲ost1host2host3嚗撠梯頝喳啣test.php
5 I7 C5 L8 C n7 g! D) b' v敺鋆∪臭誑綽RewriteCond隤乩批頛舀涉ND,憒唾OR,閬蝣箇撖怠箔9 [% R& D; l: N2 y0 A
隞乩隞蝝鄗eWrite隤瘜:; @# y) M# F1 A* e# X& g$ Z8 ]$ Y9 l
RewriteCond TestString CondPattern [Flags]
4 c, L5 n0 T+ h9 y1 J; zTestString 舀銝URL澆璇隞塚靘摮銝剔函舐啣霈詨蝔寄TTP_HOST怎批捆嚗Name= Value嚗嚗臭map嚗萄澆嚗澆鞈憿
& q' @ M3 J& V9 ?, r0 d7 A$ ACondPattern 舀隞嗅賂隞亦洵鈭靘摮箔嚗撠望host1.*
$ H) s2 s# M/ sFlags 璅霅舐洵銝賂臭誑其蝺頝銝銝璇隞塚汰R銵函內嚗憒瘝[Flags]嚗券勗怎AND嚗銵函內銝虫/ y. X- v" o- |
嗅臭誑NC蝑蝑嚗銵函內敹賜亙之撠撖嚗RewriteCond撠勗蝔撘銝剔if隤乩璅嚗銵函內憒蝚血撟曉璇隞嗅瑁RewriteCond銝Y啁RewriteRule隤伐撠望爹ewriteCond憪箇' v) T: F, H0 a
" u8 W* q* R! G% g2 jFlags 游冽:
5 h2 z* G" g$ N* {, \I (ignore case嚗銝蝞∪之撠撖怠撥銵摰摮銝脣寥嚗FLAG敶梢燎ewriteRule隞文豢RewriteCond 隞* f3 }* n/ \# T- @: O, h
F (Forbidden) 撠摰X嗥垢嚗甇㎞EWRITING蝔摨銝虫403航炊嚗瘜冽券蝔格瘜銝FORMATSTRING 舐∠函銝血臭誑閮剔蔭箔遙雿蝛箏銝脯 @+ \4 r, I& j* c# Z( k
L (last rule) 銝其遙雿撖怨嚗冽迨甇a撖怎摨嚗雿輻券FLAG隞仿餅迫嗅鋡恍撖怎URI鋡怠Y閬甈⊿撖
6 d" j1 F# X/ ]2 h! @N (Next iteration) 撘瑕買EWRITINGENGINE隤踵渲格銝虫敺剝閬瑼X伐靽格孵靽摮嚗嚗甈⊥貊崇epeatLimit摰潮塚憒詨潸N FLAG撠鋡怠蕭
0 S+ y, D" a/ p* yNS (Next iteration of the same rule) 隞代璅閮撌乩銝敺詨閬閬蝔摨嚗靘憒撘瑕園銴閬剁嚗RepeatLimit隞斗摰銝銴瑁銝閬憭扳貊殷3 m6 r9 R) R8 F7 ~' P3 b
P (force proxy) 撘瑕嗥桃URI典折典撥嗥箔誨瘙銝虫蝡喲ISAPI游隞隞瘙嚗敹蝣箄隞摮銝脫臭URI砍霅唬蜓璈蝑蝑血隞撠餈航炊
8 W. h U7 {1 {- jR (explicit redirect嚗撘瑕嗆典摰X嗥垢澆粹摰蝷箏單蝑嚗靘桃URI啣啣嚗摰閬蝬撣豢舀敺閬
8 Z! x, q2 t9 a" C6 URP (permanent redirect) 撟曆[R]璅閮詨雿舐澆301HTTP銝302HTTP隞蝣
( V2 \' A" R9 `) {U (Unmangle Log) 貸RI臭皞瘙銝舫撖恍瘙閮頛URI
( L, Q0 t& O9 \# mO (nOrmalize) 典祕銵銋璅皞摮銝脯璅皞柿RL-ENCODING嚗銝瘜摮銝脩蝘餃蝑嚗璅閮撠墀RLSURLS-ENDODED剜舀函
4 W+ \/ x2 F; _1 p* OCL (Case Lower) 撠撖
' y- t3 X( M, I' D* pCU (Case Upper) 憭批神( |, b2 `- U$ }3 c; S
暺靘鈭,閬憒雿閮剖賢祕曆餈啁,隞乩舀靘摮(.htaccess apachehttpd.conf拍冽迤閬銵函內撘):
- s) X K P" u* ?1 ?6 E7 o- .htaccess 甇斗暹潛雯蝡寧桅
- # -FrontPage-
' w/ O# f1 \" @4 k9 H, G. q7 R - IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
; ]' j" ? u3 u W% P& n& O0 @( P- F - # disable directory browsing
* W2 F3 R: M2 u G1 ? - Options All -Indexes
) b+ o$ W1 y+ K& P1 ?8 }8 l0 T# c - RewriteEngine On # 撠 RewriteEngine 璅∪
: R; g% ?0 [' b. { - RewriteBase / #閮剖箇雯蝡寧桅
+ k/ Y5 j" h& A7 y3 a: M5 \ - #4 x% J2 u0 q* @" ]
- RewriteCond %{HTTP_HOST} ^av4u.info [NC]
: m3 c( W& M& c& C1 F - RewriteRule ^(.*)$ HTTP://www.av4u.info/$1 [L]. ^' Z- U/ }1 s- Y
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$28 _: a1 T. r( ]% T/ ?# F0 F4 F# `- L
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2
5 W; M/ e7 z4 u2 X7 Z
銴鋆賭誨蝣 5 c0 r3 W1 o4 w5 i2 G6 h& M( ^' [
- Apache銋httpd.conf /etc/httpd/conf/httpd.conf銝血乩蝬脩桅畾萄銝:
- <Directory "/www/coav4u/test">* Z. `3 x8 w, y
- RewriteEngine On # 撠 RewriteEngine 璅∪
4 I: f+ R! @+ p - RewriteBase / #閮剖箇雯蝡寧桅8 Z4 g+ @7 T1 W& k9 K0 X9 ]& ^9 @& F
- RewriteCond %{HTTP_HOST} ^av4u.info [NC]
+ O8 c4 a6 P% A0 _* w& w3 s9 \ - RewriteRule ^(.*)$ HTTP://www.av4u.info/$1 [L]$ Q# `( K2 b0 V! W/ T
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2, E0 m8 y! r# o% L
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$28 K, Y* t% i6 R* G/ @# `6 d
- Options Includes FollowSymLinks
4 x& [; |3 w8 j; t - AllowOverride All- J2 ?2 D, }$ A! V% R8 ~2 |
- Allow from all3 ^; `3 G+ p2 A" E7 q+ J7 s2 [
- Order allow,deny1 W+ g/ S) U4 x
- addDefaultCharset UTF-8
8 \# D3 [- F/ o/ W - </Directory>
9 `9 t* l) Y& S: _/ }: s/ ^
銴鋆賭誨蝣 摮瑼敺閮敺httpd : service httpd restart
- ^1 L, e/ Y: X k, H/ d" b1 F
|
|