N
N
nepster-web2018-10-14 16:52:07
Nginx
nepster-web, 2018-10-14 16:52:07

How to compose a regular expression in location nginx?

There is a url like this:
/{locale}/seo/text.txt
For example:
site.com/en/seo/text.txt
site.com/ru/seo/text.txt
site.com/fr/seo/text.txt
...

I need to intercept location and change the root path, like this:

location /ru/seo {
        alias /client/www/public/seo;
}

This option works, but I need to do it with all languages, that is, something like this:
location ~ \/([a-z]{2})/seo$ {
        alias /client/www/public/seo;
    }

The problem is that it's impossible to start a regular expression in location. Tell me, please, how can this be done?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question