【Nginx】判断URL中是否存在某个参数Parameter
前言
- nginx 1.15.11(下面的代碼在此版本測試通過)
判斷URL中是否存在某個(gè)參數(shù)Parameter
假設(shè),當(dāng)URL中存在參數(shù)method=autoGenerateIndex(區(qū)分大小寫)時(shí),輸出good job;否則,輸出I'm sure it'll work out.
location ~* ^/test {#設(shè)置content typedefault_type text/html ;# HTTP Status Code 和 內(nèi)容 if ($query_string ~ ".*(?:^|\?|&)method=autoGenerateIndex(?:(?:&.*)|$)") { return 200 "Good job!"; }return 200 "I'm sure it'll work out."; }當(dāng)訪問如下地址時(shí),看到:Good job!
http://school-test.3jcf.com/test?method=autoGenerateIndex
http://school-test.3jcf.com/test?s=job&method=autoGenerateIndex
http://school-test.3jcf.com/test?method=autoGenerateIndex&s=job
當(dāng)訪問如下地址時(shí),看到:I'm sure it'll work out.
http://school-test.3jcf.com/test?method=
http://school-test.3jcf.com/test?method=add
http://school-test.3jcf.com/test?s=job&method=autogenerateIndex
http://school-test.3jcf.com/test?method=autoGenerateIndex is work
http://school-test.3jcf.com/test?s=job&method=autoGenerateIndex is work
http://school-test.3jcf.com/test?method=autoGenerateIndex is work&s=job
總結(jié)
以上是生活随笔為你收集整理的【Nginx】判断URL中是否存在某个参数Parameter的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 严重: A child containe
- 下一篇: Nginx —— 检查配置文件ngi