I just created a new structure for a website, and I need some help on redirecting to new places.
The code that works is here, but I guess this can be optimized a lot.
location = /nl {
rewrite ^ $scheme://$server_name permanent;
}
location = /nl/ {
rewrite ^ $scheme://$server_name permanent;
}
location = /en {
rewrite ^ $scheme://$server_name permanent;
}
location = /en/ {
rewrite ^ $scheme://$server_name permanent;
}
location = /nl/contact {
rewrite ^ $scheme://$server_name/contact/ permanent;
}
location = /en/contact {
rewrite ^ $scheme://$server_name/contact/ permanent;
}
rewrite ^/(en|nl)/contact$ $scheme://$server_name/contact/ permanent;
andrewrite ^/(en|nl)(/.*)$ $scheme://$server_name permanent;
order does matter in this case. Alternatively, you can combine the first 4 and last 2 location blocks with regex matches - but that does chance the matching priority (which may not be very significant).rewrite ^/(en|nl)(/?)$ $scheme://$server_name permanent; rewrite ^/(en|nl)(/contact)(/?)$ $scheme://$server_name/contact/ permanent;
Can you add this as an answer so I can close this question./contact
in brackets though - which might improve performance a tad.