10up/safe-redirect-manager

Sort by longest URL to shortest by default

roborourke opened this issue · 0 comments

Is your enhancement related to a problem? Please describe.

A while back we created some catch-all redirects for some docs, e.g. /docs/* to docs.example.com/

This covers most bases but we started adding some more specific redirects as the new docs site was changing with new pages, pages removed or moved etc...

The problem was that the oldest redirects take effect first.

Designs

Tools like Traefik that match URL patterns to map URLs to docker services use a simple default rule of treating the longest URLs as being the most specific, and process them in that order. There are additional options to set a priority or order in the case of 2 URL patterns being the same length or there being a more important catch-all URL.

The following example is a good illustration, given these 2 URLs:

  • /docs/*
  • /docs/debugging/

/docs/* would match before /docs/debugging/ and therefore /docs/debugging/ would never be used. There is currently no hint to the user this won't work without modifying the Order of the redirect.

A default processing order of longest to shortest would avoid this issue and not require intervention by users, nor the need to understand why their redirects might not be working.

Describe alternatives you've considered

This can be remedied using the existing Order field so I'd say this is low priority.

Code of Conduct

  • I agree to follow this project's Code of Conduct