The Caddyfile adapter will sort directives with the same name according to the matchers where possible, by the length of the path matcher (more characters in the matcher means it gets sorted first).
This means that any path matcher will “win” and any other kind of matcher will be sorted afterwards. There’s no valid way to sort regexps except by hand, because it’s not possible to guess how a regexp will work from outside.
You can see the order they were sorted in by running caddy adapt --config /path/to/Caddyfile --pretty which will show you the JSON for your config. Notice that the /old/*path matcher gets sorted before the path_regexp matcher in the routes.
So to work around this, you’ll need to use a route to wrap these and force the order they get executed in.
Thank you very much for the reply.
I suggest adding the description to the matcher documentation page. At least this was the place I was looking for information.