I am new to nginx. I am trying to redirect to some page ("example.com/randomText/abc") to page ("example.com/abc") with nginx.
location ~ ^/(.*/abc){
#method 1
rewrite (.*) /abc break;
#method 2
#return 301 http://$host/abc;
#method 3
#proxy_pass http://$host/abc/;
#proxy_set_header Host $host;
#proxy_set_header X-Rewrite-URL $request_uri;
}
method 1 and 2 are working but it also change the url to "http://example.com/abc" method 3 return with 502 error.
What you need is something like below