道长运维之正则表达式

背景描述

正则表达式是运维开发必经之路,我们应该深入了解这项技术,本文以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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章