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

Unified Diff: modules/web/templates/site.conf.erb

Issue 29537689: #3299 - Add URI redirect for missing translations (Closed) Base URL: https://hg1/infrastructure
Patch Set: fix comments and whitespace Created Sept. 8, 2017, 1:38 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/web/templates/site.conf.erb
===================================================================
--- a/modules/web/templates/site.conf.erb
+++ b/modules/web/templates/site.conf.erb
@@ -55,6 +55,26 @@
}
+# Redirect language URIs if no translations are found for the requested page
+
+location ~ ^/([a-z][a-z]\_[A-Z][A-Z])(/.+) {
mathias 2017/09/08 19:20:20 There's a newline missing in front of the bracket.
f.nicolaisen 2017/09/11 07:33:14 Acknowledged.
+ if (!-e "$document_root$uri")
+ {
+ # if there is no language+region translation, try parent language URI
+ # example /es_MX/page -> /es/page
+ rewrite ^/([a-z][a-z])\_([A-Z][A-Z])(/.+) /$1$3 redirect;
mathias 2017/09/08 19:20:20 This seems a bit quirky, it would move the user fr
f.nicolaisen 2017/09/11 07:33:14 Yes, this is quirky - if someone has manually chos
+ }
+}
+
mathias 2017/09/08 19:20:20 There's a newline missing in front of the bracket.
f.nicolaisen 2017/09/11 07:33:14 Acknowledged.
+location ~ ^/([a-z][a-z])(/.+) {
+ if (!-e "$document_root$uri")
+ {
+ # if there is no language translation, try canonical page for default language
+ # example /es/page -> /page
+ rewrite ^/([a-z][a-z])(/.+) $2 redirect;
+ }
+}
+
<% if @multiplexer_locations %>
<% @multiplexer_locations.each do |location| %>
location <%= location %>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld