Hello,

I migrated my D8 website from my dev (Linux) production server to a live (Windows) server. The site was in maintenance mode when I migrated it. When I took the site out of maintenance mode on production, the only page I could access was the home page. Attempting to access any other pages resulted in infinite loops. The urls looked like this: mysite.com/recipes?recipes?recipes?recipes...

I finally came across a fix described here: https://github.com/omega8cc/boa/issues/1061#issuecomment-331043217. I went to admin/config/search/redirect/settings and unckecked "Enforce clean and canonical URLs". The looping issue was resolved. Of course, all my redirects now look like this: mysite.com/recipes?recipe-url-old if I went to mysite.com/recipe-url-old and got redirected to /recipes.

What would cause this issue? What needs to be fixed in order for me to be able to re-enable that "Enforce..." setting? Is there something I should be looking for in the Windows server settings?

Here are the Windows server specs:

Windows Server 2016
IIS 10
PHP 7.2
MySql 8

Comments

hockey2112 created an issue. See original summary.

hawkeye.twolf’s picture

Priority: Normal » Critical

Bumping to "Critical" since this prevents access to all pages except <front>.

Confirmed that Disabling "Enforce clean and canonical URLs" fixed the issue. You can do that while in maintenance mode as described in the issue summary, or via drush:

drush cset redirect.settings route_normalizer_enabled 0

Perhaps until we figure out what makes this happen, the module's install config could at least not enable that setting by default. What do you think?

hawkeye.twolf’s picture

Version: 8.x-1.4 » 8.x-1.x-dev
ChristophWeber’s picture

For what it's worth, the issue and workaround are confirmed on Ubuntu 18.04, nginx 1.14, PHP 7.2, and module version 8.x-1.5.
Every time I enable the module the site goes into a redirect loop as described.

ChristophWeber’s picture

Title: Infinite redirect loop after disabling Maintenance Mode » Infinite redirect loop when route_normalizer_enabled is true
shaktik’s picture

Assigned: Unassigned » shaktik
Status: Active » Needs work
Issue tags: +DIACWApril2020
shaktik’s picture

Assigned: shaktik » Unassigned
marthinal’s picture

I had this problem in my local env with DDEV. I've upgraded to DDEV 1.15 and the issue has been fixed.

MLZR’s picture

Also confirm: direct after install the site URL was looped. After the route_normalizer_enabled set to 0 things working normal.
Drupal 9.0.6 PHP 7.4.3 + ubuntu 18 + apache

vcastillo’s picture

Same problem came up to me after installing redirect 1.6 on a Drupal 9.0.7 , all admin pages went into a loop, after setting route_normalizer_enabled to 0 it seems to fix the issue aswell.

mennovdheuvel’s picture

Had this problem today on Drupal 9.1.9 module version 8.x-1.6. Every single admin page + the user login page had infinite redirects to itself.
Deactivating the "Enforce clean and canonical URLs" through drush fixed it.

I imagine this problem was related to the setup I've got:
- Multilanguage with language selection through the hostname
- Varnish reverse proxy
- SSL

My money would be on the redirect module somehow not checking the X-forwarded-proto header for SSL, but I'm not much of a gambler.

sslam’s picture

I have this problem too.

nginx/1.21.0

SaraT’s picture

I just enabled 8.x-1.6 on a D8.9.18 site and cannot get to any of the pages on my site, including the front page. The URLs all contain many redirects as described before. Looks like nginx/1.20.1 for me.

cristiroma’s picture

We had the same problem on NGINX and the solution was to replace:

    location @rewrite {
        # Some modules enforce no slash (/) at the end of the URL
        # Else this rewrite block wouldn&#39;t be needed (GlobalRedirect)
        rewrite ^/(.*)$ /index.php?q=$1;
    }

with:

    location @rewrite {
        # Some modules enforce no slash (/) at the end of the URL
        # Else this rewrite block wouldn&#39;t be needed (GlobalRedirect)
        rewrite ^/(.*)$ /index.php?$query_string;
    }
tgoeg’s picture

Happens with Apache as well on 9.2.x

And I don't really think the webserver itself is the culprit. It can be used to mitigate the problem as shown above.
But looking at the headers in case of infinite redirects, it's clear this module produces the erroneous redirects itself.

In my case it transforms /user/login into /user/login?q=/user/login (and repetitions of this).

jpoesen’s picture

Confirming that this is still happening on my server environment (but not inside DDEV environments).

Environment:
- Ubuntu 20.04.5 LTS
- PHP 8.0.25
- web server: nginx 1.18.0
- Drupal 9.4.8
- Redirect 8.x-1.8

Steps to reproduce:
- clean standard Drupal 9 install
- fetch Redirect with composer
- enable Redirect

--> redirect loop.

Thanks.

jpoesen’s picture

We were able to fix this using the updated nginx confix posted in comment #14 (thanks, @cristiroma!):

This works for D8/D9:

    location @rewrite {
        rewrite ^/(.*)$ /index.php?$query_string;
    }

This worked for D7, but NOT for D8/D9:

  location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

If someone can post an equivalent fix for Apache, it would be good to add these to the installation instructions.

tgoeg’s picture

As already stated in #15 this should definitely *not* be encouraged and will lead to different problems.
You lose compatibility with requests that do need the ?q=<string> syntax, which is there for a cause!
The module needs to be fixed to stop the recursive requests.

jstoller’s picture

Try the patch in #3037259: Endless Redirection loop when "Enforce clean and canonical URLs" is enabled. It worked for me to solve a similar issue.

mike.roman’s picture

#2 fixed the issue for me

steinmb’s picture