Skybrud.Umbraco.Redirects
Skybrud.Umbraco.Redirects copied to clipboard
Redirects not executed when from path begins with "/media/"
Umbraco version: v8.14.0 Skybrud.Umbraco.Redirects version: v2.1.4
Using the redirects package, it appears that any redirect from a location of /media/
is not able to be processed before Umbraco's internal media handling takes over and attempts to locate the file (note that we're using Azure Blob Storage for media if that affects things). This then results in a 404 page not found response instead of the user being redirect to the destination specified in the redirect.
Examples:
- Add redirect from
/foo/bar.pdf
to content page (redirect works as expected) - Add redirect from
/media/foo/bar.pdf
to content page (redirect does not work)
It seems that Umbraco is detecting the inbound request begins with the /media/
path and the media handling process then takes over before the redirect can be executed, tries to find the file in blob storage and returns a 404 page when it cannot be found.
@alanwthom thanks for reporting 👍
I just tried spinning up a test site for 8.18, and I haven't been able to reproduce the error. I haven't tested with Azure Blob Storage yet, but ideally this shouldn't change the behavior.
To help with debugging, can you share what the <modules />
element in your root Web.config
file looks like? For one of our sites, it looks like this:
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/>
<remove name="UmbracoModule"/>
<remove name="ScriptModule"/>
<remove name="FormsAuthentication"/>
<remove name="ImageProcessorModule"/>
<add name="UmbracoModule" type="Umbraco.Web.UmbracoModule,Umbraco.Web"/>
<add name="ScriptModule" preCondition="managedHandler"
type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<!-- Needed for login/membership to work on homepage (as per http://stackoverflow.com/questions/218057/httpcontext-current-session-is-null-when-routing-requests) -->
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/>
<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web"/>
<remove name="ClientDependencyModule"/>
<add name="ClientDependencyModule" type="ClientDependency.Core.Module.ClientDependencyModule, ClientDependency.Core"/>
<remove name="RedirectsModule"/>
<add name="RedirectsModule" type="Skybrud.Umbraco.Redirects.Routing.RedirectsModule, Skybrud.Umbraco.Redirects"/>
</modules>
The redirects module is at the bottom, which shouldn't be a problem.
It might also be worth checking whether the 404 page for /media/foo/bar.pdf
actually returns 404. The redirects module only kicks in if the server responds with a 404 status code.
Hi @abjerner
Thanks for your prompt reply and apologies for the delay in mine! I can confirm the modules element of our web.config
looks similar with the redirects module appearing at the bottom. However, your note about the redirects module only kicking in when the server responds with a 404 status code set off some bells in head. Having looked into this further, we had a default custom errors redirect setup which was intended as a last chance, catch-all solution but appears to have fired before the package had a chance to take over. We've removed this now and all is good again.
Thanks for your help with this, and apologies it was user error!
No worries ;)
I couldn't reproduce the error with Azure blob storage either. I was waiting for some more time to test it, but good to hear you found the culprit 👍