Drupal 8 needs slightly different rewrite method when sending requests to /index.php than previous Drupal versions:

rewrite ^ /index.php?$query_string last;

In fact, the same new method works for Drupal 7, but we are still using Drupal 6 and Drupal 5 compatible style:

rewrite ^/(.*)$ /index.php?q=$1 last;

The problem is, the D5/D6 style causes weird problems with Drupal 8, as documented in this issue: https://github.com/pantheon-systems/drops-8/issues/105

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

memtkmcc created an issue. See original summary.

memtkmcc’s picture

Status: Active » Needs review
FileSize
3.64 KB

Attached patch should fix the problem, since it is detecting Drupal 7 or newer specific HTTP header received from the PHP backend to switch to the correct rewrite style. Not tested yet, though.

colan’s picture

Status: Needs review » Needs work
+++ b/http/Provision/Config/Nginx/Inc/vhost_include.tpl.php
@@ -1254,11 +1264,11 @@ location @drupal {
+  # if ( $query_string ~ "^amp$" ) {
+  #  rewrite ^/(.*)$  /index.php?q=$1 last;
+  # }

+++ b/http/Provision/Config/Nginx/subdir.tpl.php
@@ -1208,11 +1218,11 @@ location @drupal_<?php print $subdir_loc; ?> {
+  # if ( $query_string ~ "^amp$" ) {
+  #   rewrite ^/<?php print $subdir; ?>/(.*)$  /<?php print $subdir; ?>/index.php?q=$1 last;
+  # }

Can we remove these stanzas instead of commenting them out? Or are they temporary while you're testing?

The rest seems to match what's in https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/ so that's good.

memtkmcc’s picture

Sure, I forgot to switch branches before exporting the patch, apparently.

memtkmcc’s picture

Status: Needs work » Needs review

I have looked at this again, and I think it is OK to leave the commented out lines as proposed, because they are config examples useful when someone wants to override named location in the included extra config file to restore the previously enabled bots filtering.

colan’s picture

Status: Needs review » Reviewed & tested by the community

  • memtkmcc committed 20e6708 on 7.x-3.x
    Issue #2843473 by memtkmcc: Nginx: Use Drupal 8 friendly rewrites
    
memtkmcc’s picture

Assigned: memtkmcc » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks for the review! Patch committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.