NGINX 用 arg 重寫 url

NGINX 用 arg 重寫 url

我們需要檢查 URL 是否包含特定參數“?___store=en”,然後重定向到相同的 URL,但在網域後面加上 /en/。但這應該是動態的,因為 url 不是靜態的,並且應該能夠從每個特定頁面更改。

例如:

https://www.example.com/category1/product1?___store=en

應該重定向到:

https://www.example.com/en/category1/product1

我們已經嘗試過以下操作,但我們缺少動態部分,因為這重寫了主頁;

if ($arg____store = "en") {
    rewrite ^(.*) /en/? permanent;
}

相關內容