This solution is working fine
if ( $request_filename ~ /some-old-url/ ) {
return ^ http://www.example.com/new-url? permanent;
}
Change and match some-old-url to your old path, www.example.com to your domain and new-path to your new url, that’s all.