D
D
dexedex2015-06-13 12:10:08
Nginx
dexedex, 2015-06-13 12:10:08

Nginx, rewrite, how to remove part of URL?

The old link to site.com/asdf/qwer has changed to site.com/qwer
But user applications continue to access the old address. How to remove /asdf
from url via nginx ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2015-06-13
@dexedex

location = /asdf/qwer {
return 301 /qwer;
}

Y
Yuri, 2015-06-13
@xtreme

location ~ /asdf/ {
rewrite ^/asdf/(.*)$ /$1 break;
proxy_pass...;
#or
#root /....;
}
Or just
rewrite ^/asdf/(.*)$ /$1 break;
Most likely the second option with one rewrite in the server section is enough. Depends on the rest of the configuration.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question