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

前端 未结 10 2003
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 17:25

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

For example: My browser accept-language is \'uk,ru,en\'. When I request locati

10条回答
  •  余生分开走
    2020-12-02 17:57

    So here's the compiled example for the original question (based on my case verified to work with nginx-1.1.x):

    map $http_accept_language $lang {
        default en;
        ~ru ru;
        ~uk uk;
    }
    
    server {
        server_name mysite.org;
        # ...
        rewrite (.*) http://mysite.org/$lang$1;
    }
    

提交回复
热议问题