Let's say that i have thousand of old links that i want to redirect, all old links are like mydomain.com/1234-article-slug-name
and the new links are like mydomain.com/article-slug-name
.
I want to configure my nginx to remove article id from url and redirect to the new url.
I found my solution with apache, but can't figure it out how to achieve it on nginx.
Apache solution:
RewriteCond %{REQUEST_URI} [0-9]+-
RewriteRule ^(.*)/[0-9]+-(.*)$ $1/$2 [R=301,L]
location / { if ($request_uri ~ "[0-9]+-"){ rewrite ^/(.*)/[0-9]+-(.*)$ /$1/$2 redirect; } }