HTTPS Redirects Done Right: Avoid These Common Mistakes
A bad HTTPS redirect can break your site or create security holes. Here's how to do it properly.
Forcing HTTPS sounds simple. But done wrong, it creates redirect loops, loses SEO juice, or leaves parts of your site exposed.
The right way
You want a 301 redirect from HTTP to HTTPS, with HSTS to prevent future HTTP requests.
Common mistakes
Redirect loops
If your load balancer terminates SSL and your server also redirects, you get an infinite loop. Test with: curl -I http://yoursite.com
Mixed redirect chains
HTTP -> HTTP -> HTTPS loses link equity. You want HTTP -> HTTPS in one hop.
Missing HSTS
Without HSTS, the first visit is always over HTTP. Add the header after confirming HTTPS works everywhere.
Subdomain coverage
Use includeSubDomains in HSTS to protect all subdomains, not just the apex domain.