道長運維之正則表達式

背景描述

正則表達式是運維開發必經之路,我們應該深入瞭解這項技術,本文以IIS請求爲例將完整URL進行拆解

Regular expression should be an old friend of developer. We should look deep into this technology

URL Rewrite

URL Rewrite是IIS正則表達式應用最廣泛的模塊,該模塊預定義了一系列正則表達式參數,利用這些參數可以靈活設置重定向規則

Once a Rule or Condition matched a pattern, the system will return its value and save them into predefined variables

URL 模板

url pattern

http://domain.com:port/directory/filename[.extension]?parameterA=1&parameterB=2

{REQUEST_FILENAME}

/directory/filename[.extension]

利用該參數可迅速判斷一個請求是否被重寫或通常可以利用該參數找到請求的具體文件位置

Used to determin whether the url are trying to requrest the real path or file. Generatlly speaking, the variable can filter the requrest for real file without redirect/rewrite

{HTTP_HOST}

domain.com

{SERVER_PORT}

port

{REQUEST_URI}

/dir/filename?parameterA=1&parameterB=2

{QUERY_STRING}

parameterA=1&parameterB=2
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章