繁体   English   中英

如果 url 包含特定的查询字符串,Nginx 重定向到另一个页面

[英]Nginx redirect to another page if url contain specific query string

如果 URL 包含以 fl=&fl= 开头的查询字符串,我想将所有 URL 重定向到另一个页面

传入的 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=test0&fl=cpl;&fl=test8&fl=test9&fl=test7

以上所有 URL 都以查询字符串 fl=&fl= 开头,需要重定向到 example2.com/test123

我试过这个但没有用

if ($args = "fl=&fl=*") {
  return 301 https://example2.com/test123;
}

=运算符不理解*等通配符。 您将需要使用正则表达式语法。

例如:

if ($args ~* "^fl=&fl=") { ... }

有关详细信息,请参阅 此文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM