簡體   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