I have a site with language prefixes in $uri, for example:
Sadly, due to limitations of framework I'm using, files are also linked / looked for under prefixed addresses:
- http://www.example.com/files/image.png (this is valid and expected)
- http://www.example.com/en/files/image.png
- http://www.example.com/ru/files/image.png
What I want my nginx to do is to try files in following order:
$uri
as is/files/image.png
(even if en or ru or any other two-letter code was present)/index.php
to get file generated if applicable
1. and 3. can be (are) done with simple:
location / {
try_files $uri /index.php;
}
I know about ~* command to tell Nginx to do a regex match (source). Sadly, I have no idea how to formulate match to omit potential group instead of selecting it. And trying with variables before and after made me try to use if
- of course I want to avoid that.
I believe I'm missing something relatively simple.