I post here even if its probably more a SF question I think it could interest some of you.
Is there a way to tell with Regex to nginx if, for example, the 3rd catpure groupe is match redirect to that else to that ?
Example : We have 2 types of URL :
circuit/asie/indonesie/denpasar-bali/
or circuit/asie/indonesie/
and we want to redirect to
asie/indonesie/denpasar-bali/
or asie/indonesie/
Let say we have this Regex : \w+\/([^\/]+)\/([^\/]+)\/?([^\/]+)?\/
How do you say if match the first case redirect to the first url and match the second redirect to the second ?
Does something like this could work ?
rewrite \w+/([^/]+)/([^/]+)/?([^/]+)?/ /$1/$2/?$3?/ permanent;