Endless Redirection loop when using Domain access

Created on 4 March 2019, almost 6 years ago
Updated 14 February 2023, almost 2 years ago

I have a website with multiple domains. I'm using domain access so each node has a source domain and some contents are available on several domains.

With the redirect module enable, when I go to a node with a different source domain, it redirect me to the domain source of the node.
That give me a endless redirection loop error

Following this discussion β†’ , the issue is that Redirect, like Drupal core, doesn't check for changes to the hostname before acting.

I manage to make it partially word with some improvement ( See code #13 β†’ ) on the following feature :
RouteNormalizerRequestSubscriber::onKernelRequestRedirect():

diff --git a/src/EventSubscriber/RouteNormalizerRequestSubscriber.php b/src/EventSubscriber/RouteNormalizerRequestSubscriber.php
--- a/src/EventSubscriber/RouteNormalizerRequestSubscriber.php
+++ b/src/EventSubscriber/RouteNormalizerRequestSubscriber.php
 
 /**
  * Normalizes GET requests performing a redirect if required.
@@ -125,7 +125,7 @@ class RouteNormalizerRequestSubscriber implements EventSubscriberInterface {
       $original_uri = urldecode($original_uri);
       $redirect_uri = urldecode($redirect_uri);
+	   
+  	   $original_uri_parsed = parse_url($original_uri);
+  	   $redirect_uri_parsed = parse_url($redirect_uri);  
+      $original_uri_path = $original_uri_parsed['path']; 
+      $redirect_uri_path = $redirect_uri_parsed['path'];
+      // Should we also compare : .'?'.$original_uri_parsed['query'].'#'.$original_uri_parsed['fragmant'];
+
-      if ($redirect_uri != $original_uri) {  
+      if ($redirect_uri_path != $original_uri_path) {
	   
         $response = new TrustedRedirectResponse($redirect_uri, $this->config->get('default_status_code'));
         $response->headers->set('X-Drupal-Route-Normalizer', 1);
         $event->setResponse($response);
         // Disable page cache for redirects as that results in unpredictable

Could you help me to improve this patch ?

✨ Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡±πŸ‡ΊLuxembourg nambroise

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024