【Nginx】判断URL中是否存在某个参数Parameter
前言
- nginx 1.15.11(下面的代碼在此版本測試通過)
判斷URL中是否存在某個參數Parameter
假設,當URL中存在參數method=autoGenerateIndex(區分大小寫)時,輸出good job;否則,輸出I'm sure it'll work out.
location ~* ^/test {#設置content typedefault_type text/html ;# HTTP Status Code 和 內容 if ($query_string ~ ".*(?:^|\?|&)method=autoGenerateIndex(?:(?:&.*)|$)") { return 200 "Good job!"; }return 200 "I'm sure it'll work out."; }當訪問如下地址時,看到: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
當訪問如下地址時,看到: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
總結
以上是生活随笔為你收集整理的【Nginx】判断URL中是否存在某个参数Parameter的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 严重: A child containe
- 下一篇: 一键抠图换背景相册大师一键抠图换背景