nginx中的等效重写规则是什么?

我在Apache2中有这个重写规则

 RewriteRule country / usa [/] * $ / en / country / united-states [L,R = 301,NC]

我试图在nginx中构build一个等效的重写规则

服务器{
重写^ country / usa [/] * $ / en / country / united-states last;
 #虚拟主机的剩余部分
 }

但是这并没有工作:(任何想法如何做到这一点?
谢谢你的帮助

类似于下面的代码应该做的工作:

server { ... rewrite ^/country/usa$ /en/country/united-states permanent; } 

这将仅以301 Moved Permanently状态redirect/country/usa/country/usa/ 。 另一种select是

 server { ... rewrite ^/country/usa([/])?(.*)$ /en/country/united-states/$2 permanent; } 

这将把包括/country/usa在内的所有内容redirect到新的位置。
例如/country/usa/testing将进入/en/country/united-states/testing

http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

>redirect – 返回代码302的临时redirect; 如果replacestring不以“http://”或“https://”开头,则使用该string;

永久 – 返回代码为301的永久性redirect。