1

I am attempting to rewrite incoming uri requests to http://core/api/token to simply http://token. I have tried successfully to do this by specifying variables in the location block:

rewrite ${INBOUND_ENDPOINT} ${REDIRECT_ENDPOINT} break;

BUT I have been asked to use regex in an if statement to just take the last part of any incoming uri to just use the last part, in this case /token.

Any help is appreciated. Thanks in advance.

Update:

I tried to use something like this and had no luck either:

server {
  listen 80;
  server_name example.com;

Handle favicon.ico requests separately to prevent unwanted redirects

location = /favicon.ico { return 204; }

location / { # Use an if statement to match and capture the final part of the path if ($request_uri ~* ^.*/([^/]+)$) { # Rewrite the URI to use only the final part of the path set $final_part $1; rewrite ^ /$final_part break; } } }

kovshenin
  • 210

0 Answers0