Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 # Puppet: <%= @title %> | |
mathias
2018/03/27 14:46:52
Please don't simply copy from our legacy. There's
| |
2 | |
3 root /var/www/<%= @domain %>; | |
4 index index; | |
5 default_type text/html; | |
6 charset utf-8; | |
7 | |
8 set $index_page "index"; | |
9 | |
10 <% if @custom_config %> | |
11 <%= @custom_config %> | |
mathias
2018/03/27 14:46:52
We know the two spaces in front of the custom conf
f.lopez
2018/03/27 19:29:50
Acknowledged.
| |
12 <% end %> | |
13 | |
14 location / | |
15 { | |
16 expires 1d; | |
17 | |
18 # Redirect server/language root | |
19 | |
20 rewrite ^/$ /$index_page last; | |
21 rewrite ^/(\w\w(_\w\w)?)$ /$1/ permanent; | |
22 rewrite ^/(\w\w(_\w\w)?)/$ /$1/$index_page last; | |
23 | |
24 # Match Accept-Language header against available languages | |
25 | |
26 set $preferredLang en; | |
27 set $preferredRegion ""; | |
mathias
2018/03/27 14:46:52
Please avoid camel case where possible, and always
f.lopez
2018/03/27 19:29:51
Acknowledged.
| |
28 if ($http_accept_language ~ ^(\w\w)\b) | |
mathias
2018/03/27 14:46:52
An empty line in front of this block would be appr
f.lopez
2018/03/27 19:29:51
Acknowledged.
| |
29 { | |
30 set $preferredLang $1; | |
31 } | |
32 if ($http_accept_language ~ ^\w\w-(\w\w)\b) | |
33 { | |
34 set $preferredRegion $1; | |
35 } | |
36 | |
37 if ($arg_fb_locale ~ ^(\w\w)_(\w\w)$) | |
38 { | |
39 set $preferredLang $1; | |
40 set $preferredRegion $2; | |
41 } | |
42 | |
43 # Redirect canonical URLs to language-specific versions | |
44 | |
45 if (-e "$document_root/${preferredLang}_$preferredRegion$uri") | |
46 { | |
47 rewrite ^(.*) /${preferredLang}_$preferredRegion$1 last; | |
48 } | |
49 if (-e "$document_root/$preferredLang$uri") | |
50 { | |
51 rewrite ^(.*) /$preferredLang$1 last; | |
52 } | |
53 if (-e "$document_root/en$uri") | |
54 { | |
55 rewrite ^(.*) /en$1 last; | |
56 } | |
57 } | |
58 | |
59 # Redirect language URIs if no translations are found for the requested page | |
60 | |
61 location ~ ^/([a-z][a-z]\_[A-Z][A-Z])(/.+) | |
mathias
2018/03/27 14:46:52
Why use [a-z] here but \w above?
Why use [A-Z] her
f.lopez
2018/03/27 19:29:51
Not sure, gonna try it with \w, I reused what we a
f.lopez
2018/03/28 16:05:09
This is because how the translations pages are bui
| |
62 { | |
63 if (!-e "$document_root$uri") | |
64 { | |
65 # if there is no language+region translation, try parent language URI | |
66 # example /es_MX/page -> /es/page | |
67 rewrite ^/([a-z][a-z])\_([A-Z][A-Z])(/.+) /$1$3 redirect; | |
68 } | |
69 } | |
70 | |
71 location ~ ^/([a-z][a-z])(/.+) | |
72 { | |
73 if (!-e "$document_root$uri") | |
74 { | |
75 # if there is no language translation, try canonical page for default langua ge | |
76 # example /es/page -> /page | |
77 rewrite ^/([a-z][a-z])(/.+) $2 redirect; | |
78 } | |
79 } | |
OLD | NEW |