This page is about Caddy 2, which is currently in beta. Click here for the old Caddy 1 site. Thank you for your patience as we transition!


Issues an HTTP redirect to the client.

This directive implies that a matched request is to be rejected. It is ordered very early in the handler chain (before rewrite).


redir [<matcher>] <to> [<code>]
  • <to> is the target location. Becomes the response's Location header.
  • <code> is the HTTP status code to use for the redirect. Can be:
    • A positive integer in the 3xx range
    • temporary for a temporary redirect (302; default)
    • permanent for a permanent redirect (301)
    • html to use an HTML document to perform the redirect (useful for redirecting browsers but not API clients)


Redirect all requests to


Same, but preserve the existing URI:


Same, but permanent:

redir{uri} permanent