handle /foo* {
respond /foo/bar "you are at /foo/bar"
respond /foo "you are at /foo"
}
At first glance this seems unintuitive to me — if you’ve already matched /foo in handle /foo* why do you need to match it again in respond /foo/bar "you are at /foo/bar"? I have unsuccessfully tried searching through issues and PRs as I’m interested to find the context behind this, would someone be able to point me in the right direction?
Because it was otherwise impossible to match on just / for example to only handle requests to the root of your site. It’s as simple as that. Caddy v1’s design made it hard or impossible to do all kinds of simple config tasks.
Because it breaks things if we start messing with the path (we tried this in v1 - there are a bunch of other issues/forum posts but I can’t find them right now).
Matching a request is totally different from rewriting a request.
The proposal for handle_path is specifically for use cases where you want to both match AND rewrite a request based on its path prefix.