That’s not right. expression
is a matcher type, not a directive.
handle_errors {
@404 {
expression {http.error.status_code} == '404'
}
respond @404 "Oops 404 Try again"
}
If you want to display some 404.html page, you can use rewrite
instead of respond
. That part was just for explanatory purposes.
If you’re confused about matchers, read this page in the docs: Request matchers (Caddyfile) — Caddy Documentation