I have a web server which accepts https://www.example.com/API/ooo/xxx, https://www.example.com/API/aaa/bbb, and https://www.example.com/API/xxx/yyy ... etc.
Now we want to redirect the above quests to https://www.example.com/ooo/xxx, https://www.example.com/aaa/bbb, and https://www.example.com/xxx/yyy ... etc.
I've tried using rewrite key word in nginx:
location /API/ {
rewrite ^/API(.*)$ https://$host$1 redirect;
}
This works for GET requests. But it turns POST requests to GET requests. This is something I don't want.
How can I preserve the http method while redirecting /API/* to /*?
This post says that I can use 307 redirect. But rewrite doesn't seem to support 307 redirect. And I can't figure out how to use $1 regular expression property in return.