
Resolving Redirect URL Issues in Umbraco 8 After Assigning a Culture and Hostname
Umbraco, Redirects
When managing multilingual or multi-domain websites in Umbraco 8, it is common to assign a culture and hostname to the root content node. However, doing so can inadvertently disrupt existing redirect URLs, particularly if those redirects were established prior to the hostname configuration.
In this post, we will examine why this occurs and how to resolve it using a straightforward SQL-based approach.
Background
Umbraco stores redirect URLs in the umbracoRedirectUrl table. When content is moved or renamed—or when custom redirect functionality is in use—Umbraco typically creates entries in the format:
/old-page
These entries are mapped to a content key that points to the new destination.
However, when a culture and hostname are assigned to the root node, Umbraco alters its behaviour. Redirects are now expected to include the root node's ID as a prefix, resulting in URLs such as:
1058/old-page
As a result, any redirect URLs stored prior to the hostname change no longer match the expected format and will cease to function correctly.
The Solution
To restore functionality to existing redirects, two SQL updates can be applied:
-- Step 1: Prefix existing redirect URLs with the root node ID (replace 1058 with your actual node ID) UPDATE dbo.umbracoRedirectUrl SET url = '1058' + url WHERE url NOT LIKE '1058/%' -- Step 2: Recalculate the URL hash to match Umbraco's expected format UPDATE dbo.umbracoRedirectUrl SET urlHash = LOWER(CONVERT(NVARCHAR(255), HASHBYTES('SHA1', LTRIM(RTRIM(LOWER(CONVERT(VARCHAR(MAX), url))))), 2))
Important Notes:
- Ensure you replace 1058 with the actual ID of your homepage or root node.
- These queries assume all affected redirects require the same node ID prefix.
- If a culture and hostname are ever removed, the reverse logic applies—you would remove the node ID prefix instead of adding it.
Compatibility
This approach has been validated in Umbraco 8. While the redirect storage model appears similar in later versions, this has not been tested against Umbraco 9+. If you intend to apply this fix to newer versions, confirm that the schema and redirect behavior remain consistent.
Always back up your database before executing direct SQL modifications.
Conclusion
Assigning a culture and hostname in Umbraco can lead to unexpected issues with legacy redirects. Fortunately, with a couple of well-targeted SQL updates, you can restore proper redirect behaviour and ensure a seamless experience for users and search engines alike.
If you have encountered similar issues in newer versions or in more complex multi-site setups, feel free to share your experience or adaptations.