Redirection Hosts#

Redirection hosts issue HTTP redirects from one domain (or path) to another. They are useful for:

  • Redirecting www.example.com → example.com (or vice versa)
  • Redirecting an old domain to a new one after a migration
  • Sending a vanity URL to a longer canonical URL

Creating a redirection host#

  1. Click Redirections in the sidebar
  2. Click + Add Redirection Host
  3. Fill in the form:
FieldDescription
Domain NamesThe incoming domain(s) to redirect from (press Enter after each)
Forward Schemehttp or https — the scheme of the destination URL
Forward Domain NameThe destination domain
HTTP CodeThe redirect status code (301, 302, 307, or 308)
Preserve PathIf enabled, appends the request path to the destination
SSL CertificateOptional — select a certificate if you want to redirect HTTPS → HTTPS
  1. Click Create
Add Redirect Rule form sending old.example.com to www.example.com

Unsaved example redirect with documentation-only domains.

Status codes#

CodeTypeDescription
301Moved PermanentlyBrowser caches the redirect. Use for permanent domain changes.
302Found (Temporary)Temporary redirect; caching also depends on response headers.
307Temporary RedirectLike 302, but preserves the HTTP method (POST stays POST).
308Permanent RedirectLike 301, but preserves the HTTP method.

For permanent migrations, use 301. For A/B testing or temporary maintenance pages, use 302.

Preserve Path#

When Preserve Path is enabled, the original request path is appended to the destination:

https://old.example.com/blog/post-1
          ↓  (301, Forward Domain: new.example.com, Preserve Path: on)
https://new.example.com/blog/post-1

When disabled, all requests to the source domain redirect to the bare destination domain.

SSL on redirecting domains#

If you want to redirect https://old.example.com (rather than just http://), you need a certificate for old.example.com. Either:

  • Enable Force HTTPS without an assigned custom certificate to use Caddy’s automatic issuance (public DNS/challenge reachability is required)
  • Upload a custom certificate on the Certificates page and select it

Enable / disable#

Redirection hosts can be toggled without deleting them. Removal takes effect after configuration application succeeds. Check the configuration notice for offline agents and failed applications.

PosternProxyQuick start →