url rewriting – How to detect location more intelligently in Nginx config file?
I’m trying to use location
to detect the current locale and transfer (rewrite) the request in my Nginx config file.
This is a my configuration:
location /ru
{
rewrite ^/ru/(.*)$ /$1?local=ru;
rewrite ^/ru /?local=ru;
}
So, I intend to change domain.tld/ru/blog
to domain.tld/blog?locale=ru
.
But I have encountered one problem. As an example, the URL domain.tld/russell
would interfere with this config blog.
I want to be able to get more specific for location
syntax. I want to tell Nginx to run this block only and if only the URL starts with a two-letter ru
path segment.
How can I do that?
Read more here: Source link