nginx with angular 4

Viewed 3391

i'm having trouble for my config here is how i want to work mydomain.com -> redirect to correct language : mydomain.com/en/ or mydomain.com/fr/

I have two angular build with i18n, one for each language. the redirection with language works, but direct links with angular 2 not : if i go to mydomain.com/fr/connect -> 404

Here is my nginx configuration

map $http_accept_language $lang {
   default en;
   ~*^fr fr;
}

server {
    listen 80;
    server_name domain.com www.domain.com;
    root /usr/share/nginx/html;
    index  index.html index.htm;
    location = / {
        rewrite "^.$" /$lang/ break;
    }
    location = /$lang/ {
        try_files $uri $uri/ /index.html;
    }
}

if some of you know this, i'm just stuck there, i'm a nginx begginner :/

1 Answers
Related