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

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

Issue 4808447505727488: Issue 2301 - Improve beta.adblockplus.org configuration (Closed)
Patch Set: Created April 15, 2015, 12:20 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
Index: modules/web/templates/site.conf.erb
===================================================================
--- a/modules/web/templates/site.conf.erb
+++ b/modules/web/templates/site.conf.erb
@@ -1,76 +1,56 @@
expires 1d;
root /var/www/<%= vhost %>;
index index;
default_type text/html;
charset utf-8;
+set $index_page "index";
+
<% if @custom_config %>
<%= custom_config %>
<% end %>
-# Match Accept-Language header against available languages
+location /
+{
+ # Match Accept-Language header against available languages
Wladimir Palant 2015/04/15 12:23:29 This comments makes little sense now, I'll change
-set $preferredLang "";
-if ($http_accept_language ~ ^(\w\w)-(\w\w)\b)
-{
- set $preferrredLang $1_$2;
-}
-if (!-f $document_root/$preferredLang/index)
-{
- set $preferredLang "";
-}
+ set $preferredLang en;
+ set $preferredRegion "";
+ if ($http_accept_language ~ ^(\w\w)\b)
+ {
+ set $preferredLang $1;
+ }
+ if ($http_accept_language ~ ^\w\w-(\w\w)\b)
+ {
+ set $preferredRegion $1;
+ }
-set $temp "$preferredLang|$http_accept_language";
-if ($temp ~ ^\|(\w\w)\b)
-{
- set $preferredLang $1;
-}
-if (!-f $document_root/$preferredLang/index)
-{
- set $preferredLang "";
-}
+ # Redirect canonical URLs to language-specific versions
-if ($preferredLang = "")
-{
- set $preferredLang "en";
-}
+ if (-f "$document_root/${preferredLang}_$preferredRegion$uri")
+ {
+ rewrite ^(.*) /${preferredLang}_$preferredRegion$1 last;
+ }
+ if (-f "$document_root/$preferredLang$uri")
+ {
+ rewrite ^(.*) /$preferredLang$1 last;
+ }
+ if (-f "$document_root/en$uri")
+ {
+ rewrite ^(.*) /en$1 last;
+ }
-# Always redirect server root
+ # Redirect server/language root
-rewrite ^/$ /$preferredLang/ last;
-
-# Don't do anything if requested file exists
-
-if (-f $request_filename)
-{
- break;
-}
-if (-d $request_filename)
-{
- break;
-}
-
-# Redirect canonical URLs to language-specific versions
-
-set $canonical $uri;
-if ($canonical ~ ^(.*?)\?)
-{
- set $canonical $1;
-}
-
-if (-f $document_root/$preferredLang$canonical)
-{
- rewrite ^ /$preferredLang$canonical last;
-}
-if (-f $document_root/en$canonical)
-{
- rewrite ^ /en$canonical last;
+ rewrite ^/$ /$index_page last;
+ rewrite ^/(\w\w(_\w\w)?)$ /$1/ permanent;
+ rewrite ^/(\w\w(_\w\w)?)/$ /$1/$index_page last;
}
<% if @multiplexer_locations %>
<% @multiplexer_locations.each do |location| %>
location <%= location %>
{
fastcgi_pass unix:/tmp/multiplexer-fastcgi.sock;
include /etc/nginx/fastcgi_params;

Powered by Google App Engine
This is Rietveld