Skip to content

Splat redirects should not be applied to other matching redirects #1221

@nickserv

Description

@nickserv

Describe the bug

Splat redirects are always applied to matching paths, even if there's another matching path higher up. According to Rule processing order and Netlify deploy previews, only the first matching rule should be used.

This makes one site difficult to develop with because many URLs that are valid on Netlify are redirected to 404s.

To Reproduce

Visit localhost:8888/a

Configuration

[[redirects]]
  from = "/a"
  to = "/docs/a"

[[redirects]]
  from = "/docs/*"
  to = "/docs/b/:splat"
  System:
    OS: macOS 10.15.6
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 300.75 MB / 8.00 GB
    Shell: 3.1.2 - /usr/local/bin/fish
  Binaries:
    Node: 14.9.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  npmGlobalPackages:
    netlify-cli: 2.61.2

Expected behavior

Should redirect to /docs/a as Netlify only matches the first redirect

Actual behavior

Redirects to /docs/b/a after incorrectly matching the splat redirect as well

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions