2017-03-11 33 views
0

我們已經從舊系統遷移到新網站。我有很多舊的URL看起來像這樣:符合查詢字符串的NGINX重定向

/index.php?id=1&groep=26

/site/index.php?id=1&groep=10

新網址的樣子:

/medical-information/test-results

沒有格局重寫這些URL的每必須手動完成。

如何將這些重定向到NGINX?它看起來與index.php部分之後的查詢字符串不匹配。

非常感謝!

回答

2

我會建議使用帶有$ arg_groep和重寫的地圖。
http://nginx.org/en/docs/http/ngx_http_map_module.html
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

您可以在這裏找到
https://serverfault.com/questions/609042/nginx-map-directive-for-multiple-variables一個例子。

我的建議。

map $arg_groep $dest { 
    26 /medical-information/test-results; 
    10 /some/other/URL; 
} 

rewrite ^/index.php?id=1&groep=26 $dest permanent; 

您將通過此搜索查詢查找更多示例。
https://www.startpage.com/do/dsearch?query=nginx+map+args