I understand that redirects are case-sensitive because URLs are case-sensitive by design, and the general guidance offered is to create multiple redirects to support additional cases.
In our case, we cannot create variants of the redirects for mixed-cases because the redirects are sourced from a CMS and represent marketing / short URL redirects, rather than API rewrites that we have control over how they are used. The permutations would be too many. However, a situation where a user types in a URL in mixed case and gets a 404 rather than being redirected is not ideal.
Are Edge Handlers a potential solution to this? Could they be used to rewrite the incoming URL into lowercase before it is then processed? Or perhaps isntead issuing a 301 response to the lowercase variant of a URL, if it is detected that it is in mixed case? We would just apply this logic to the path and not the query.
Are there other solutions that can be done within Netlify?
Unfortunately this post did not provoke a response, but I can say that in our case we were able to handle this situation with a function. I’ll provide this information in case it helps someone else trying to solve this problem.
First, the function is set as a fallback redirect:
from = '/*'
to = "/.netlify/functions/redirects"
status = 200
force = false
As part of our build we read the 404 file content and then store this for the function, along with a collection of all of the redirects for matching. During execution, the function will match the given path against the known redirects and return a 301 if one is found. If no match is found, the function will instead return a 404 status, along with the content out of the 404 page.
That’s awesome, glad you found a fix! A function is a really good solution since you can use it to check urls and redirect appropriately. Edge handlers would be a smidge faster since it runs alongside the content at the CDN level and doesn’t require a trip to the origin, but this is a perfectly cromulent solution
We are implementing something almost identical to what you are describing.
Our lists of redirects approaches 10,000, and we did not want to impede performance of _redirects file itself.
Only catching unmatched files/pages on the back-end won’t impact regular traffic then.
do keep us posted on how this works out, @moop-moop !