Problem/Motivation
This relates to #2821158: Guide users who enter path aliases to use internal paths instead
Redirects are matched against system paths. So a redirect from node/123 also redirects /foo-bar, the alias of that node. Drupal turns /foo-bar into node/123 before it looks for a redirect (inbound path processing).
When the alias is deleted, that stops. The published URL returns a 404 and nothing warns the user.
Deleting the node does the same, because its aliases are deleted with it.
This is usually the point of the redirect: the editor wants /foo-bar (the canonical path) to keep pointing to /somewhere once the node is gone.
Steps to reproduce
- Create a node (e.g. /node/123) with the URL alias (e.g. /foo-bar).
- Create a redirect from node/123 to /somewhere.
- Visit /foo-bar, it redirects to /somewhere.
- Delete the /foo-bar alias (or the node).
- Visit /foo-bar, it is a 404.
Proposed resolution
When a path alias is deleted, copy the redirect for its system path to the alias path so the published URL then keeps redirecting.
This is opt-in, behind a new setting (off by default).
Remaining tasks
Review.
User interface changes
A checkbox on the redirect settings form, "Keep redirects working when a URL alias is deleted", off by default.
API changes
None.
Data model changes
None.
Issue fork redirect-3620838
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
herved commentedComment #3
herved commentedComment #5
herved commentedComment #6
herved commentedThree choices are not obvious from the diff:
Not copied, same as today: a language neutral alias with a language specific redirect, and a source with a query string.
---
Let me know if this is something you would consider for the module. I can also adapt the approach if needed.
Comment #7
herved commented