How to rewrite location in nginx depending on the client-browser’s language?

You can manage $language_suffix by this setting when you cannot add AcceptLanguageModule module into your system.

rewrite (.*) $1/$http_accept_language

A more resilient approach would use a map:

map $http_accept_language $lang {
        default en;
        ~es es;
        ~fr fr;
}

...

rewrite (.*) $1/$lang;

Leave a Comment

tech