http.status

status writes a status code to the response. It does not write a response body.

Syntax

status *code path*

  • code is the HTTP status code to respond with (must be numeric).
  • path is the base request path to match.

If you have a lot of status rewrites to group, share a status code by making a table:

status *code* { *path* }

Each line describes a base path which should have that status code written.

Examples

For a catch-all status:

status 404 /

To hide the existence of a secret folder:

status 404 /secrets

To hide the existence of multiple folders:

status 404 { /hidden /secrets }

Need help with this feature?

Join us in the Caddy forum, where the open source community gathers to share their knowledge.

Does your company use Caddy?

Purchase a commercial license to use Caddy with your business and for basic email support, along with other benefits!