I’m curious how people are setting up redirects in Umbraco 17.
We have used Skybrud Redirects a lot previously, but for U17 that package has issues when using multiple languages, and the two latest versions we can’t hit the “save” button when creating new redirects so we can’t use that any more.
Is there any service/api within Umbraco to set up redirects? Or do you usually solve it with some proxy layer ahead of Umbraco maybe? Curious to see the experience of others as we’re a bit lost on redirects at the moment!
We usually use Skybrud to be honest have you raised an issue on GitHub for them? They are really responsive. Last time I had an issue it was picked up and released after than most paid for things these days
We use Skybrud Redirects on Umbraco 17 and not noticed any issues, although we’ve not got any multi-lingual sites on 17 yet so maybe we’re not hitting the same issue. I’m not really sure there’s an alternative if you want the redirects to be manageable from the backoffice unless you implement something custom. Hopefully they will fix it soon.
I’m souring on solutions like Skybrud Redirects. It’s a great package, but the premise is fundamentally flawed in Umbraco because it fires too late in the pipeline.
The redirects happen once content finders have fired and Umbraco is about to serve a 404. For a path that we know ahead of time will redirect Umbraco still tries to look content up, then look for its own redirects (database hit), before beginning to return a 404, then the middleware kicks in to lookup the redirect (another database hit) before actually doing the redirect.
What happens when the marketing team pop a nice little /nyc → /new-york redirect and put that URL in a massive email campaign…?
So for scenarios like that we put the redirect in Cloudflare. If we need to handle a couple of URLs in Cloudflare, then it makes sense for all of them to be there.
I’m toying with the idea of making my own Redirects package for Umbraco that’s just a UI for the Cloudflare API.
You have plugins, you can build your own plugins, and there are official plugins. Redirects fits as one of them in their world, I think Umbraco should be similar in that regard.
When using Cloudflare for redirects, do you need to use their Load balancer or is that part of the default solution?
All the URL management changes that have been in an ongoing direction since 8 have been challenging to adjust to.
I ended up writing a full custom 404 handling solutions to overcome some of the structural changes, especially with culture and multiple sites.
If a 404 is triggered it looks for the page throughout to find if it is in a new location and loads. Works well but was annoying it was needed.
Other plugin creators such as invisible nodes (needed because again, you used to just make Document types without templates and they did not generate a URL, not really the case any more) and I know he had some challenges to get it to work with the current Umbraco.
Since v7 we have been using our own solution, which has proven to be quite good. Otherwise there is no editor, but there is a txt file where all redirect pairs are entered. Then we simply have a custom ContentFinder.cs → TryFindContent(IPublishedRequestBuilder contentRequest) where we do what we want in order: check if it is a front end or back end request → if the node is published → check the redirect table → recursively check back along the path for the slug if it exists → check browser lang detection etc. If it finds a node, it displays it or redirects it. If everything fails then it throws a custom 404. The part of the code that reads the redirects file into the cache is:
`// not founded
// look redirects
// redrect example:
// ``http://site.localtest.me/it/john/?a=123``, ``http://site.localtest.me/sl/mike/ann/``
// ``http://site.localtest.me/calendar/``, ``http://site.localtest.me/sl/event/``
Dictionary<string, string> redirects = _common.Redirects();
if (redirects != null && redirects.ContainsKey(_common.AddLastSlash(_common.AbsolutePageUrl(false))))
{
if (_common.AbsolutePageUrl(true) != redirects[_common.AddLastSlash(_common.AbsolutePageUrl(false))])
{
// redirect found -> move and END
contentRequest.SetRedirectPermanent(redirects[_common.AddLastSlash(_common.AbsolutePageUrl(false))]);
return Task.FromResult(true); ;
}
}`