Is this the proper way to use an NGINX rewrite to strip a subdirectory off a request?

Posted February 16, 2021 77 views

I’m using a location block to respond to requests at but I want requests for resources like /v3/accounts/ to be passed to the application as simply /accounts/.

I’ve configured the following rewrite rule in the location block, but I was reading about taxing rewrites in the NGINX docs and I was hoping somebody could tell me if I’ve written the wrong type of regex for this rewrite:

 rewrite ^/v3/(.*)$ /$1 break;

Thank you!

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!