Redirect does not work if alias exists for non-existent node.

Created on 12 October 2021, almost 4 years ago
Updated 18 August 2025, 22 days ago

Problem/Motivation

If a URL alias exists for a node that does not, and you set up a redirect from the alias to somewhere else, the redirect does not apply. Instead you hit a 404 error. This happened to us in after a site migration where a contact form changed from a node to a regular form, so the alias came in when we bulk imported the aliases from the old site but the node did not.

This is a bit of an edge case since normally aliases are deleted when a node is deleted. But, if for some reason this didn't happen then we end up with this issue.

Steps to reproduce

- Create an alias for a non-existent node, either manually in the db or with something like https://www.drupal.org/project/path_alias_import β†’
- Create a redirect from /that-alias to /somewhere-else
- Navigate to /somewhere-else

Proposed resolution

Add handling for redirects from 404 pages, and potentially other 4xx pages. I'd image this might be a small change to RedirectRequestSubscriber.php

πŸ› Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mrweiner

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

Comments & Activities

Not all content is available!

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

  • πŸ‡«πŸ‡·France dqd London | N.Y.C | Paris | Hamburg | Berlin

    Seems to be an early report overlapping with πŸ› Redirects from aliased paths aren't triggered Needs work . Since this is an active issue in MR status over there, let us mark this one here as duplicate, because it pops up firsto n Google. The other issue started 2017 and is in almost RTBC, so I think it's OK.

Production build 0.71.5 2024