Rewrite guest view

Hi,

is it possible to rewrite the URL https://invoice.domain.com/guest/view/invoice/2LRypc1i4ZlHJvs to https://invoice.domain.com/invoice/2LRypc1i4ZlHJvs and the same for quotes?

I tried something like this:

location /invoice/ {
    rewrite ^(.*)$ https://invoice.domain.com/guest/view/invoice/ last;
}

but this won’t work, also tried many other things, I’ve found on the web.