Redirect HTTP to HTTPS with a permanent response

For a permanent move, use a server-side 301 or 308 redirect to the HTTPS version of the requested page. Keep the path and query string so an old link still reaches the content it names.

How do I force HTTPS on my host?

HostWhere to set the HTTPS redirectSource
CloudflareTurn on Always Use HTTPS after the affected hosts work over HTTPS.Always Use HTTPS
nginxUse a separate HTTP server block with a return directive pointing at the HTTPS destination.Separate server blocks and return
ApacheUse Redirect permanent in a dedicated HTTP virtual host; use the documented rewrite approach if only .htaccess is available.Forcing HTTPS
VercelHTTP requests already receive a 308 redirect to HTTPS from the CDN.Encryption and TLS
NetlifyUse protocol-specific redirect rules when a host needs an explicit redirect, and assign the source domain to the site.Domain-level redirects

Add HSTS after the HTTP to HTTPS redirect works

Once every HTTP address redirects, add the Strict-Transport-Security header to your HTTPS responses. Leave it off the redirect itself, since browsers ignore the header when it arrives over HTTP. The HSTS reference explains why.

Frequently asked questions

Why does forcing HTTPS cause too many redirects?

Your CDN and your server can disagree about whether a request already uses HTTPS. On Cloudflare's Flexible mode, for example, Cloudflare reaches your server over plain HTTP, so a server rule that sends HTTP to HTTPS causes a loop. Cloudflare's redirect loop guide covers each setting, and Apache's guide covers servers behind a proxy.

  • Domain health

    Fix the setup mistakes that make browsers warn people away from your site.

  • HSTS

    Understand how browsers remember HTTPS before extending that rule to every subdomain.

  • Mixed content

    Replace insecure file and form addresses that remain on an HTTPS page.

  • Redirects

    Choose the right redirect for a move and remove unnecessary steps to the destination.