Nginx return under location
You want to rewrite the URI and redirect. You can achieve it using location
and return
directives, but a rewrite
directive would be the simplest approach:
rewrite ^/new(.*)$ https://new-service.company.com$1 permanent;
See this document for more.
BTW, the problem with your location
block solution, was the regular expression capture, wasn't. Use:
location ~ ^/new(.*)$ { return 301 https://new-service.company.com$1$is_args$args;}
See this document for more.