How to match only / with http.status

It is possible to match only / with status?

I want to return a 403 on the index, but status 403 / is a catch-all.

This is the default behavior in Caddy 2. I recommend upgrading:

respond / 403
1 Like

Great! Is there any update guide or is v2 backwards-compatible?

There is no official update guide and the v2 Caddyfile has breaking changes from v1.

The v2 Caddyfile docs are here: The Caddyfile — Caddy Documentation

If you do not wish to upgrade, you can get around this problem in v1 by using a quick rewrite hack. {
  rewrite {
    # Check for exact path
    if {path} is /
    # Internal rewrite to some path for status to operate on
    to /forbidden
  status 403 /forbidden

I do intend to write an upgrade guide if time/funding permits.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.