Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/web/templates/site.conf.erb

Issue 29538581: #3421 - Do root rewrite before rewriting to translated page (Closed) Base URL: https://hg1/infrastructure
Patch Set: more details in commit msg Created Sept. 11, 2017, 8:48 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 root /var/www/<%= @vhost %>; 1 root /var/www/<%= @vhost %>;
2 index index; 2 index index;
3 default_type text/html; 3 default_type text/html;
4 charset utf-8; 4 charset utf-8;
5 5
6 set $index_page "index"; 6 set $index_page "index";
7 7
8 <% if @custom_config %> 8 <% if @custom_config %>
9 <%= @custom_config %> 9 <%= @custom_config %>
10 <% end %> 10 <% end %>
11 11
12 location / 12 location /
13 { 13 {
14 expires 1d; 14 expires 1d;
15 15
16 # Redirect server/language root
17
18 rewrite ^/$ /$index_page last;
19 rewrite ^/(\w\w(_\w\w)?)$ /$1/ permanent;
20 rewrite ^/(\w\w(_\w\w)?)/$ /$1/$index_page last;
21
16 # Match Accept-Language header against available languages 22 # Match Accept-Language header against available languages
17 23
18 set $preferredLang en; 24 set $preferredLang en;
19 set $preferredRegion ""; 25 set $preferredRegion "";
20 if ($http_accept_language ~ ^(\w\w)\b) 26 if ($http_accept_language ~ ^(\w\w)\b)
21 { 27 {
22 set $preferredLang $1; 28 set $preferredLang $1;
23 } 29 }
24 if ($http_accept_language ~ ^\w\w-(\w\w)\b) 30 if ($http_accept_language ~ ^\w\w-(\w\w)\b)
25 { 31 {
(...skipping 14 matching lines...) Expand all
40 } 46 }
41 if (-e "$document_root/$preferredLang$uri") 47 if (-e "$document_root/$preferredLang$uri")
42 { 48 {
43 rewrite ^(.*) /$preferredLang$1 last; 49 rewrite ^(.*) /$preferredLang$1 last;
44 } 50 }
45 if (-e "$document_root/en$uri") 51 if (-e "$document_root/en$uri")
46 { 52 {
47 rewrite ^(.*) /en$1 last; 53 rewrite ^(.*) /en$1 last;
48 } 54 }
49 55
50 # Redirect server/language root
51
52 rewrite ^/$ /$index_page last;
53 rewrite ^/(\w\w(_\w\w)?)$ /$1/ permanent;
54 rewrite ^/(\w\w(_\w\w)?)/$ /$1/$index_page last;
55 } 56 }
56 57
57 <% if @multiplexer_locations %> 58 <% if @multiplexer_locations %>
58 <% @multiplexer_locations.each do |location| %> 59 <% @multiplexer_locations.each do |location| %>
59 location <%= location %> 60 location <%= location %>
60 { 61 {
61 fastcgi_pass unix:/tmp/multiplexer-fastcgi.sock; 62 fastcgi_pass unix:/tmp/multiplexer-fastcgi.sock;
62 include /etc/nginx/fastcgi_params; 63 include /etc/nginx/fastcgi_params;
63 } 64 }
64 <% end %> 65 <% end %>
65 <% end %> 66 <% end %>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld