Problem/Motivation
Starting in Drupal 11, if more than one alias exists for a node and a user requests one of the secondary aliases, the AliasManager no longer sets the response using the canonical alias. Instead, it simply uses whatever URL the user requested if it exists as an alias. This impacts the Redirect module's ability to "Enforce clean and canonical URLs" which, in turn, no longer causes an automatic redirect to the canonical when a secondary alias is requested. This is different from the behavior of previous versions of Drupal (8/9/10).
Steps to reproduce
- Ensure the redirect module is installed and the "Enforce clean and canonical URLs" setting is on (default)
- Create a new node and give it an alias such as /canonical
- Go to the administer aliases page (/admin/config/search/path) and add a new alias for the node you just created such as /alias
- Visit the /alias URL in a browser. You will not be redirected to /canonical as you would have been in D8/9/10
Proposed resolution
Restore AliasManager's ability to lookup and use the canonical URL for a node instead of relying on whatever the user has entered.
Issue fork drupal-3585268
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
cilefen commentedIt would be ideal to know which commit to AliasManager changed the behavior. It could have been an important bug fix, for example.
Comment #3
mdziedzic commentedI believe it may have originated here:
https://www.drupal.org/project/drupal/issues/3496369
https://git.drupalcode.org/project/drupal/-/commit/4ba82cdcf4e8d72e18b617d4b7dad621829c346c
Comment #5
mdziedzic commentedComment #6
quietone commentedHi, Issues for Drupal core should be targeted to the 'main' branch, our primary development branch. Changes are made on the main branch first, and are then back ported as needed according to the Core change policies. The version the problem was discovered on should be stated in the issue summary Problem/Motivation section. Thanks.
Comment #7
smustgrave commentedThank you for reporting!
As mentioned the MR will need to be pointed to main first and then potentially backported. Also as a bug will need a test case showing the issue please
Thanks.