Skip to content

Redirect tracking: Ensure redirects with domains are stored with the domain node id prefix (closes #20894)#20900

Merged
Zeegaan merged 5 commits intomainfrom
v17/bugfix/handle-redirects-with-domains
Nov 20, 2025
Merged

Redirect tracking: Ensure redirects with domains are stored with the domain node id prefix (closes #20894)#20900
Zeegaan merged 5 commits intomainfrom
v17/bugfix/handle-redirects-with-domains

Conversation

@AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Nov 19, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

Fixes #20894

Description

As the linked issue describes, when we have a redirect created for a node under a root that has a domain assigned, we should be storing the integer ID of the node with the domain assigned as a prefix to the route. Looking back over the history, it seems this was lost in this update: #17491

In this PR I've restored it such that a redirect between /page-1 and /page-1a under a root with a domain assigned will be stored as e.g. 1058/page-1a.

Testing

Set up as per the linked issue and create a redirect under one of the site roots.

With this update in place, you should see the domain listed correctly in the redirect tracker list.

image

From what I understand in the linked report, that should also lead to a functioning redirect:

The only way I made this work is by manually adding the domainRootId in the database entry

And from testing I have verified that is the case. To do this locally, I've registered multiple local URLs via this addition in Program.cs:

WebApplication app = builder.Build();
builder.WebHost.UseUrls("https://localhost:44339", "https://localhost:44340");

You can then assign the localhost:44339 as one domain on a site root and localhost:44340 on another and follow the reproduction steps on the linked issue.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR restores the functionality to store redirect URLs with domain node ID prefixes when content is under a root with an assigned domain. The fix addresses issue #20894 where redirects for content under domain-assigned roots were not being stored correctly, causing them to not function properly.

Key changes:

  • Added IDomainCache dependency to RedirectTracker to check for domain assignments
  • Modified both StoreOldRoute and CreateRedirects methods to prepend domain root ID to routes when applicable
  • Added test coverage for the domain prefix functionality

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Umbraco.Infrastructure/Routing/RedirectTracker.cs Added IDomainCache dependency injection and logic to prepend domain root ID to routes in both storage and creation phases
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Routing/RedirectTrackerTests.cs Refactored existing tests and added new test Can_Store_Old_Route_With_Domain_Root_Prefix to verify domain prefix functionality

AndyButland and others added 2 commits November 19, 2025 19:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to do a double take cause I was looking in the wrong place 🤦 But when you actually look at the correct place, it works like a charm 🚀 And it fixes future redirects 😁

@Zeegaan Zeegaan merged commit 75dd9fa into main Nov 20, 2025
25 of 26 checks passed
@Zeegaan Zeegaan deleted the v17/bugfix/handle-redirects-with-domains branch November 20, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi site url tracker ignores domainRootId

2 participants