麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 網(wǎng)站 > Apache > 正文

apache url rewrite及正則表達(dá)式筆記

2024-08-27 18:29:18
字體:
供稿:網(wǎng)友
apache url rewrite及正則表達(dá)式筆記

  

什么是mod_rewrite?

mod_rewrite是apache一個(gè)允許服務(wù)器端對(duì)請(qǐng)求url做修改的模塊。入端url將和一系列的rule來比對(duì)。這些rule包含一個(gè)正則表達(dá)式以便檢測(cè)每個(gè)特別的模式。如果在url中檢測(cè)到該模式,并且適當(dāng)?shù)念A(yù)設(shè)條件滿足,name該模式將被一個(gè)預(yù)設(shè)的字符串或者行為所替換。

這個(gè)過程持續(xù)進(jìn)行直到?jīng)]有任何未處理的規(guī)則或者該過程被顯式地停止。

這可以用三點(diǎn)來總結(jié):

  • 有一系列的順序處理的規(guī)則rule集
  • 如果有一條規(guī)則被匹配,將同時(shí)檢查該規(guī)則對(duì)應(yīng)的條件是否滿足
  • 如果一切處理結(jié)果都是go,那么將執(zhí)行一條替換或者其他動(dòng)作
mod_rewrite的好處

有一些比較明顯的好處,但是也有一些并不是很明顯:

mod_rewrite非常普遍地被用于轉(zhuǎn)換丑陋的,難以明義的URL,形成所謂"友好或干凈的url"。

另一方面,這些轉(zhuǎn)換后的url將會(huì)是搜索引擎友好的

正則表達(dá)式token:

/s{2,}  2個(gè)以上的空格

/|    backward referrence

//    matches a '/'

/b    Word boundary position,比如whitespace或者字符串的開始或者結(jié)束

/B    Not a word boundary position

(?=ABC)  positive lookahead. Matches a group after your main exPRession without including it in the result

(?!ABC)  Negative lookahead.Specifies a group that can not match after your main expression(ie. if it matches, the result is discarded)

(?<=ABC) Positive lookbehind. Matches a group before your main expression without including it in the result.

(?<!ABC)  Negative lookbehind.Specifies a group that can not match before your main expression(ie.if it matches, the result is discarded)

*?    :match zero or more of the preceeding token. This is a lazy match, and will match as few characters as possible before satisfying the next token

+?    :match one or more of the preceeding token. This is a lazy match, and will match as few characters as possible before satisfying the next token

{5}    :matches exactly 5 of the preceeding token;

{2,5}  : matches 2 to 5 of the preceding token. Greedy match;

{2,5}?  matches 2 to 5 of the preceding token. lazy match;

(ABC)  groups multiple tokens together. This allows you to apply quantifiers to the fall group. Creates a capture group roll over a match highlight to see the capture group result

(?:ABC)  groups multiple tokens without creating capture group;

$$    escaped $ symbol       $`: insert the portion of the string that precedes the match

$&:    inserts the matched substring $' : insert the portion of the string that follows the match[$1]:    inserts the result of the first capture group

m      multiline

i       ignore case

"S"      match any character, except for line breaks if dotall is false

"g"    search globally

?    zero or one

/    escape

/.  //  /+  /*  /?  /^  /$  /[  /]  /(  /)  /{  /}  //  /'  /#

[ABC]  Any single character in ABC set

+    one or more

*    zero or more

|  or matches the full before or after '|'      (https?|ftp)://

^    matches the beginning of the string    

$    matches the end of the string

$1    refer to a match

$2    refer to another match

?:  within parenthesis to not capture (^.+(?:jpg|png|gif)$)

[^ABC]   Any single character not in the set

[a-z]    any single character in the a-z range

[^b-e]    any single character that is not in range b-e

[0-9]

[/w'-]  any world characater, single quote or -

/t  /r/n  tab

/xFF    specifying a character by its hexdecimal index

/xA9 => copyright symbol


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 日韩视频一区二区在线观看 | 蜜桃传媒视频麻豆第一区免费观看 | 久久精品一区二区三区不卡牛牛 | 91福利影视 | 久久久www成人免费精品 | 一区二区久久久久草草 | av播放在线| 国产91av视频 | 一级做人爱c黑人影片 | 国产午夜精品视频免费不卡69堂 | 干色视频| 成人男女啪啪免费观看网站四虎 | 亚洲成人黄色片 | 91久久久久久久 | 精国产品一区二区三区四季综 | 精品视频在线免费看 | 免费看毛片的网站 | 特级无码毛片免费视频尤物 | 草草视频免费 | 中文字幕线观看 | 性生活视频软件 | 宅男视频在线观看免费 | 精品国产一区二区三区成人影院 | 成人短视频在线观看免费 | 日韩欧美色综合 | 久久99国产综合精品 | 热久久成人 | 一级做a在线观看 | 韩日黄色片 | av在线免费观看不卡 | 免费在线观看毛片视频 | 中文字幕欧美专区 | 偿还电影免费 | 高清国产午夜精品久久久久久 | 97超碰资源站| 国产成年免费视频 | 亚洲精品成人在线视频 | 中文字幕综合在线观看 | 久久9久久 | 免费观看黄色一级视频 | 中文字幕在线一 |