Domain alias redirect loop

Created on 24 August 2023, over 1 year ago
Updated 21 September 2023, about 1 year ago

Drupal Version: 9.5.10

Domain module version: 1.0.0-beta8

Expected Behavior

I have a domain that has two aliases for each environment. One alias is a (302) redirect, the other is not.
My goals is to have all URLs that come in on the redirect alias to be redirected to the other alias.

Actual Behavior

The site has multiple domains, and on most domains the setup as described above worked wel.
Though on one of the domains it resulted in an endless redirect loop.

After some debugging I figured out that the redirect alias, when sorted alpabetically, would end up above the non redirect alias.
As the other domains (by coincidence) didn't have that, I altered the `id` of the non redirect alias to be listed above the redirect alias when alphabetically ordered. That ended up solving the issue.

Steps to reproduce

- Create a domain
- Create an alias for env 'local'. Prefix the machine name with c_
- Create another alias with env 'local' with a 302 redirect. Prefix the machine name with b_
- Go in your browser to the redirect alias and witness an endless redirect loop.

Steps to fix the issue
- Update the first alias you created. Prefix the machine name with a_ instead of c_.
- Go in your browser to the redirect alias and witness a proper redirect without an endless loop.

I've tried to alter the source code to fix the issue but didn't get far.
If a maintainer could lend a hand on this that would be greatly appreciated.

πŸ› Bug report
Status

Needs review

Component

- Domain Alias

Created by

πŸ‡³πŸ‡±Netherlands boazpoolman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @boazpoolman
  • gaurav gupta Jaipur, Rajasthsan

    Gaurav Gupta β†’ made their first commit to this issue’s fork.

  • πŸ‡ΊπŸ‡ΈUnited States agentrickard Georgia (US)

    The alias system isn't wired to redirect from one alias to another nor to be used in the manner you describe.

    The redirect setting is designed to redirect from the alias to the associated domain's canonical URL. See line 114 of domain/src/EventSubscriber/DomainSubscriber.php

    The type of complex handling you are looking for is best handled in .htaccess or similar. Alias redirects are for users who don't have access to such tools.

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    93 pass
  • πŸ‡ΊπŸ‡ΈUnited States agentrickard Georgia (US)

    Try this. If it doesn't work, it likely is a feature request for the reasons listed above.

  • πŸ‡³πŸ‡±Netherlands boazpoolman

    Thanks for looking at this issue Rickard!

    I've applied your patch, and removed my `a_` prefix workaround, though sadly the redirect loop still occurs.
    What is our next course of action? Do you want me to rebrand this issue to be a feature request?

Production build 0.71.5 2024