From 45583defa81286c10d4844e6e177f24db764a038 Mon Sep 17 00:00:00 2001 From: memtkmcc Date: Sat, 14 Jan 2017 02:49:41 +0100 Subject: [PATCH] Issue #2843473 by memtkmcc: Nginx: Use Drupal 8 friendly rewrites --- .../Config/Nginx/Inc/vhost_include.tpl.php | 33 ++++++++++++++++++---- http/Provision/Config/Nginx/subdir.tpl.php | 29 ++++++++++++++++--- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/http/Provision/Config/Nginx/Inc/vhost_include.tpl.php b/http/Provision/Config/Nginx/Inc/vhost_include.tpl.php index 476fb07..bb98776 100644 --- a/http/Provision/Config/Nginx/Inc/vhost_include.tpl.php +++ b/http/Provision/Config/Nginx/Inc/vhost_include.tpl.php @@ -1245,7 +1245,17 @@ location @drupal { return 418; } - rewrite ^/(.*)$ /index.php?q=$1 last; + ### + ### For Drupal >= 7 + ### + if ($sent_http_x_generator) { + add_header X-Info-Gen "Modern"; + rewrite ^ /index.php?$query_string last; + } + ### + ### For Drupal <= 6 + ### + rewrite ^/(.*)$ /index.php?q=$1 last; } @@ -1254,11 +1264,11 @@ location @drupal { ### location @nobots { ### - ### Support for Accelerated Mobile Pages (AMP). + ### Support for Accelerated Mobile Pages (AMP) when bots are redirected below ### - if ( $query_string ~ "^amp$" ) { - rewrite ^/(.*)$ /index.php?q=$1 last; - } + # if ( $query_string ~ "^amp$" ) { + # rewrite ^/(.*)$ /index.php?q=$1 last; + # } ### ### Send all known bots to $args free URLs (optional) @@ -1274,7 +1284,18 @@ location @nobots { if ( $args ~* "=PHP[A-Z0-9]{8}-" ) { return 404; } - rewrite ^/(.*)$ /index.php?q=$1 last; + + ### + ### For Drupal >= 7 + ### + if ($sent_http_x_generator) { + add_header X-Info-Gen "Modern"; + rewrite ^ /index.php?$query_string last; + } + ### + ### For Drupal <= 6 + ### + rewrite ^/(.*)$ /index.php?q=$1 last; } ### diff --git a/http/Provision/Config/Nginx/subdir.tpl.php b/http/Provision/Config/Nginx/subdir.tpl.php index e979fdf..fb28ceb 100644 --- a/http/Provision/Config/Nginx/subdir.tpl.php +++ b/http/Provision/Config/Nginx/subdir.tpl.php @@ -1199,6 +1199,16 @@ location @drupal_ { return 418; } + ### + ### For Drupal >= 7 + ### + if ($sent_http_x_generator) { + add_header X-Info-Gen "Modern"; + rewrite ^ //index.php?$query_string last; + } + ### + ### For Drupal <= 6 + ### rewrite ^//(.*)$ //index.php?q=$1 last; } @@ -1208,11 +1218,11 @@ location @drupal_ { ### location @nobots_ { ### - ### Support for Accelerated Mobile Pages (AMP). + ### Support for Accelerated Mobile Pages (AMP) when bots are redirected below ### - if ( $query_string ~ "^amp$" ) { - rewrite ^//(.*)$ //index.php?q=$1 last; - } + # if ( $query_string ~ "^amp$" ) { + # rewrite ^//(.*)$ //index.php?q=$1 last; + # } ### ### Send all known bots to $args free URLs (optional) @@ -1228,6 +1238,17 @@ location @nobots_ { if ( $args ~* "=PHP[A-Z0-9]{8}-" ) { return 404; } + + ### + ### For Drupal >= 7 + ### + if ($sent_http_x_generator) { + add_header X-Info-Gen "Modern"; + rewrite ^ //index.php?$query_string last; + } + ### + ### For Drupal <= 6 + ### rewrite ^//(.*)$ //index.php?q=$1 last; } -- 2.10.1 (Apple Git-78)