Answer HTTP with a redirect to HTTPS
Why it matters
Nothing answers on http://, so visitors who type the bare domain without a remembered HSTS policy may get a connection error. Answering port 80 with a permanent redirect sends them to the https site.
The fix
- Allow port 80 through the firewall and any cloud security group.
- Make the web server listen on port 80 for example.com and answer every request with a 301 redirect to https://example.com and the same path.
- If the site is behind Cloudflare or another CDN that connects to this server over plain http (Cloudflare Flexible mode), this redirect loops. Switch the CDN to Full (strict) first, or redirect at the CDN instead (Always Use HTTPS).
http
HTTP/1.1 301 Moved Permanently Location: https://example.com/
The examples use example.com. Replace it with your own domain.
Related
- Reported by the HTTP to HTTPS redirect check
- Serve the site over HTTPS
- Stop redirecting HTTPS to HTTP
- Redirect HTTP to HTTPS
- Fix the broken HTTPS redirect chain
- Shorten the redirect chain
- Fix the HTTP redirect chain
- Redirect HTTP straight to HTTPS
- Redirect www and apex to one host
- Make the www or apex name work over HTTPS
Scan your domain to see whether this applies to you.