I'm trying to redirect urls with Ninx but i'm struggling to get it right:
example.com/{dynamic1}/foo/bar/{dynamic2}
to example.com/{dynamic1}/bar/{dynamic2}
basically i'm trying to remove the /foo/
portion of the url.
i've tried the following:
location ~* ^/(.*)/foo/bar/(.*)$ {
return 302 ^/$1/bar/$2?$args;
}
and also:
location ~ ^/([^/]*)/foo/bar/(.*)$ {
return 302 ^/$1/bar/$2?$args;
}
but this throws the error 414 Request-URI Too Large
and the url ends up being (shortened for clarity):
dynamic1/cams/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/%5E/dynamic1/bar/dynamic2?
What am I doing wrong?
Note that once i get this right i will replace 302 with 301.