HTTP to HTTPS redirects: 301 or 308, and how many hops are too many

By TechCompare · Updated · How we check

Answer every HTTP request with a 301 or 308 to the same path on HTTPS. Keep the chain to one or two hops, and go to HTTPS on the same host before switching to www.

Old links, bookmarks and some apps still point at http:// addresses. The server should answer those with a permanent redirect to the HTTPS address. Do it in one hop where you can. Each extra hop is another round trip before the page starts loading, and long chains are where mistakes like redirect loops hide.

Topic
HTTP to HTTPS redirect
Redirect chains
Category
HTTPS setup
HSTS, ECH, redirects and compression

How this is calculated

301 and 308 both mean moved permanently, and browsers and search engines treat them that way. The difference is the request method. A 308 has to keep it, so a POST stays a POST. A 301 lets clients turn a POST into a GET, and most do. For ordinary page loads the two act the same. The temporary codes, 302 and 307, tell search engines to keep the old address, so they don't belong here.

Keep the path and the query. Sending http://example.com/pricing to the HTTPS home page breaks every old deep link and throws away the value of links to those pages.

Order matters when www is involved. http://example.com should go to https://example.com first, then to https://www.example.com if www is your main name. Jumping straight from http://example.com to https://www.example.com saves a hop, but then the bare domain never sets its HSTS header over HTTPS, and the preload list at hstspreload.org wants the first redirect to stay on the same host.

Watch for loops. A CDN that talks to your server over plain HTTP, while the server redirects everything to HTTPS, can bounce a request back and forth until the browser gives up with too many redirects.

The SSL Checker starts at http:// on your host and follows every redirect, listing each URL with its status code until something other than a redirect answers. It stops at a loop or a long chain and says why.

Verdict

Use one permanent redirect from HTTP to HTTPS on the same host, keeping the path and query, then at most one more hop to your main host name. Check the chain after any CDN or server change. A chain longer than two hops, or one that doesn't end on HTTPS, needs fixing.

More SSL scenarios

Frequently asked questions

Should I use 301 or 308 for HTTPS redirects?
Either works for browsers and search engines. Use 308 when forms or API clients send POST requests to HTTP addresses, so the method and body survive. For normal pages, 301 is the common choice.
Does the redirect alone keep visitors safe?
No. The first request still goes out over plain HTTP, where someone on the network could change the answer. HSTS fixes that for returning visitors, and the HSTS preload list fixes it for first visits too.
Why does the checker show a different chain than my browser?
Your browser may skip plain HTTP entirely, because of HSTS or because it tries HTTPS first. The checker always starts from http:// and doesn't remember HSTS or earlier redirects, so it shows what a first-time visitor or a crawler gets.