R
R
Rockman2016-09-21 12:05:42
Nginx
Rockman, 2016-09-21 12:05:42

How to set up nginx redirect correctly?

There is such processing in nginx-e

location / {
    	try_files $uri $uri/ /index.php?$args;
  }

It is necessary to add the conditions that when accessing domain.com/ru or domain.com/ru/ (instead of ru there may be codes of other languages), this request was processed not as a request to an existing directory, but as /index.php?$args But when In this case, if after /ru/ there are some other characters, for example /ru/images/, then the processing would already be according to the rules
location / {
    	try_files $uri $uri/ /index.php?$args;
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sundukov, 2016-09-21
@1Rockman

Something like this:

location ~* ^/([a-z]{2}) {
    	try_files $uri $uri/ /index.php?$args;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question