Reputation: 1775
I have this Nginx rule:
location /fr {
rewrite ^/(fr)(?:/([^/]+))?$ /$2?lang=$1 last;
}
I have pages such as:
example.com/en/some-page
example.com/fr/some-page
example.com/fr
...
But I also have a page which starts by fr
:
example.com/free-plan // doesn't work
example.com/fr/free-plan // doesn't work either
How can I modify my Nginx rule so that the /fr
rule doesn't interference with my free-plan
page?
Ps: I use PHP and rules to service page without the extension:
location / {
try_files $uri $uri.html $uri/ @extensionless-php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
Upvotes: 1
Views: 59
Reputation: 49682
I would suggest that you treat /fr
as a special case and use location /fr/
to avoid side-effects from pages that begin with fr
.
For example:
location = /fr {
rewrite ^/(.*)$ /?lang=$1 last;
}
location /fr/ {
...
}
See this document for details.
Upvotes: 1