[英]Nginx redirect to another page if url contain specific query string
I want to redirect all URLs to another page if the URL contains a query string starting with fl=&fl=如果 URL 包含以 fl=&fl= 开头的查询字符串,我想将所有 URL 重定向到另一个页面
incoming URL's can be anything starting with the query sting fl=&fl=传入的 URL 可以是任何以查询字符串 fl=&fl= 开头的内容
https://example.com/a-core/?fl=&fl=test&fl=test1&fl=xyz;&fl=test3&fl=test4&fl=test5 https://example.com/a-core/?fl=&fl=test&fl=test1&fl=xyz;&fl=test3&fl=test4&fl=test5
https://example.com/a-core/?fl=&fl=test&fl=test0&fl=cpl;&fl=test8&fl=test9&fl=test7 https://example.com/a-core/?fl=&fl=test&fl=test0&fl=cpl;&fl=test8&fl=test9&fl=test7
all of the above URLs are starting with query string fl=&fl= and need to be redirected to example2.com/test123以上所有 URL 都以查询字符串 fl=&fl= 开头,需要重定向到 example2.com/test123
I have tried this but didn't work我试过这个但没有用
if ($args = "fl=&fl=*") {
return 301 https://example2.com/test123;
}
The =
operator does not understand wildcards such as *
. =
运算符不理解*
等通配符。 You will need to use regular expression syntax.您将需要使用正则表达式语法。
For example:例如:
if ($args ~* "^fl=&fl=") { ... }
See this document for details.有关详细信息,请参阅 此文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.