HSTS: HTTP Strict Transport Security dla SEO

co HSTS actually robi, the Strict-Transport-Security header syntax (max-age, includeSubDomains, preload), the przeglądarka-tylko internal redirect crawlers nigdy see, why it doesn't zastępować twój 301s, i how preload może lock you in — z Patrick Stox.

Opublikowano po raz pierwszy: 3 lip 2026 · Ostatnia aktualizacja: 3 sie 2026 · Advanced
Języki
1 sygnał dowodowy na tej stronie

HSTS (HTTP Strict Transport Security) jest a Strict-Transport-Security nagłówek odpowiedzi — honored tylko gdy it arrives ponad a secure connection — że tells a przeglądarka to zawsze używać HTTPS dla twój domain going forward, closing the insecure gap że a new visitor's pierwszy żądanie nadal makes ponad HTTP przed twój 301 fires. It's a przeglądarka-warstwa, per-client polityka on top of twój serwer-side redirects, nie a replacement: RFC 6797 ma the przeglądarka rewrite the URI to HTTPS internally przed dowolny żądanie goes out (często shown as an internal 307-style redirect, though the RFC doesn't mandate a specific kod stanu), so no serwer ever sees the HTTP form i crawlers nadal need twój rzeczywisty 301 to zrozum move i carry link equity. The header ma three directives — max-age (required), includeSubDomains, i preload. Preload bakes twój domain do the przeglądarka itself via hstspreload.org (requiring max-age of co najmniej a year, includeSubDomains, i the preload flag) i jest close to irreversible — removal jest a oddzielny submission że takes months to reach użytkownicy. HSTS jest również deliberately unforgiving: a przeglądarka że knows you as an HSTS host będzie trudny-fail z no click-przez if twój certificate ever breaks. So enable it tylko once HTTPS jest genuinely solid w całym każdy subdomain, i treat preload as a one-way door.

TL;DR — HSTS jest the Strict-Transport-Security nagłówek odpowiedzi, honored tylko gdy a przeglądarka receives it ponad a secure connection, i stored per-client as future polityka dla że host. It closes the “first request problem” a 301 alone leaves otwarty: the initial HTTP żądanie z a new visitor jest insecure until the redirect fires, i że’s the window an SSL-stripping attacker wants. Three directives: max-age (required, seconds), includeSubDomains, preload. gdy a przeglądarka enforces HSTS it rewrites the URI to HTTPS internally, przed dowolny żądanie reaches a serwer — RFC 6797 doesn’t mandate a specific kod stanu dla że rewrite, though narzędzia często surface it as a 307 — so twój serwer-side 301s są nadal mandatory dla wyszukiwarki i link equity; HSTS jest on top of them, nie instead. Preload bakes twój domain do the przeglądarka via hstspreload.org (wymaga max-age ≥ 31536000, includeSubDomains, i preload) i jest close to irreversible — removal jest a oddzielny submission że takes months to reach użytkownicy. i HSTS jest designed to trudny-fail on dowolny cert błąd, so enable it tylko gdy HTTPS jest robust w całym każdy subdomain.

The HTTPS hub introduces HSTS as a przeglądarka-warstwa protection że sits on top of twój 301s. ten strona jest the deep dive: the dokładny header syntax, the internal redirect że trips SEOs up, the preload lista’s near-irreversibility, i the rzeczywisty-world ways HSTS locks people out.

The problem HSTS actually solves: the pierwszy żądanie

Picture a properly migrated witryna. każdy http:// URL 301-redirects to jego https:// twin, the certificate jest prawidłowy, canonicals point to HTTPS. Looks airtight. It isn’t, quite.

gdy a marka-new visitor types yoursite.com (no scheme) lub clicks an old http://yoursite.com link, the przeglądarka’s pierwszy żądanie goes out ponad plain HTTP. twój serwer answers z the 301, i każdy żądanie po że jest secure. ale że one initial round-trip happened in the jasny — i że’s exactly the window an SSL-stripping attacker on the same network wants. They intercept the HTTP żądanie, zachowaj victim on HTTP podczas gdy they proxy HTTPS to twój serwer, i read lub rewrite everything.

HSTS eliminates że window dla anyone who ma visited przed. web.dev jest bezpośredni o the mechanism: “use Strict Transport Security to tell clients they should always connect to your server using HTTPS, even when following an http:// reference. This defeats attacks like SSL Stripping, and avoids the round-trip cost of the 301 redirect.” (web.dev). że ostatni clause matters dla wydajność too: a returning przeglądarka skips the HTTP→HTTPS round-trip entirely. Evidence for this claim After receiving HSTS, a browser upgrades future HTTP attempts to HTTPS before sending the request. Scope: MDN documents user-agent enforcement after the header has been learned; first-visit protection requires preload or a prior secure visit. Confidence: high · Verified: MDN: Strict-Transport-Security header

Two granica conditions worth będąc precise o. pierwszy, HSTS jest stored, per-client polityka — it lives in że one przeglądarka’s own state dla że host, learned z a header delivered ponad a secure connection; the same header sent on an HTTP odpowiedź jest ignored outright (an attacker who może inject lub strip headers on plain HTTP mógł otherwise neutralize it), i a client że ma nigdy received it — a fresh install, a różny przeglądarka, a crawler — ma no polityka to enforce. Second, the rewrite jest scheme-i-port aware: an implicit port 80 żądanie becomes an implicit port 443 żądanie, ale if the original URI named an explicit non-domyślny port, the przeglądarka zachowuje że same port liczba i simply contacts it ponad HTTPS instead.

The header syntax

HSTS jest one nagłówek odpowiedzi z up to three directives. Per MDN, the forms są:

Strict-Transport-Security: max-age=31536000
Strict-Transport-Security: max-age=31536000; includeSubDomains
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
  • max-age=<seconds> — required. “The time, in seconds, that the browser should remember that a host is only to be accessed using HTTPS” (MDN). 31536000 jest one year; 63072000 jest two. The clock resets on każdy odpowiedź że carries the header, so an active witryna continually renews jego polityka. ten jest relative, per-client state: simply removing the header doesn’t immediately jasny it — a przeglądarka że już learned the polityka zachowuje enforcing it until jego stored max-age runs out. To turn HSTS off dla clients że już learned it, you mieć to actively serve max-age=0 ponad a secure odpowiedź; the przeglądarka then forgets the polityka on jego następny secure visit. (max-age=0 clears a learned polityka tylko — it robi nie remove a domain z the oddzielny preload lista.)
  • includeSubDomains — optional. “If this directive is specified, the HSTS policy applies to all subdomains of the host’s domain as well” (MDN). Powerful i dangerous in equal mierzyć — see the lockout scenarios below.
  • preload — optional. A flag że signals twój intent to być on the przeglądarka preload lista. It robi nothing on jego own; it’s a prerequisite dla submitting to hstspreload.org. Evidence for this claim HSTS preload requires at least a one-year max-age, includeSubDomains, and preload; removal can take months to reach users. Scope: The Chromium preload service documents submission and removal behavior; requirements can change and should be rechecked before submission. Confidence: high · Verified: Chromium: HSTS Preload List Submission

The behavior, again z MDN: “Before loading an http URL, the browser checks the domain name against its HSTS hosts list. If the domain name is a case insensitive match for an HSTS host or is a subdomain of one that specified includeSubDomains, then the browser replaces the URL scheme with https.”

The internal upgrade crawlers nigdy see (ten jest the SEO crux)

Here’s the single najbardziej misunderstood thing o HSTS, i the powód it może’t zastępować twój redirects.

gdy a przeglądarka upgrades an http:// żądanie poniżej HSTS, it rewrites the URI to HTTPS internally, przed dowolny network żądanie jest made — RFC 6797 wymaga the scheme substitution itself ale robi nie mandate a particular kod stanu dla it (RFC 6797 §8,3), so a given przeglądarka lub crawling narzędzie może represent że internal krok however it likes — wiele display it as an internal 307, ale że’s client/narzędzie-specific, nie a protokół guarantee. co matters dla SEO jest simpler i holds regardless of the label: no serwer jest contacted dla the HTTP version, so no crawler ever sees it. Googlebot i Bingbot don’t carry a learned HSTS polityka around the way a returning człowiek’s Chrome robi — they hit twój serwer fresh, i co they need to see there jest a rzeczywisty, serwer-side 301. Evidence for this claim RFC 6797 requires the user agent to rewrite a known-HSTS-host HTTP URI to HTTPS internally, but does not mandate any specific redirect status code for that internal rewrite; how a given browser or crawling tool represents that step (e.g., as an internal 307) is a client/tool implementation detail, not a protocol requirement. Scope: RFC 6797 Section 8.3 ("URI Loading and Port Mapping") specifies the UA MUST replace the URI scheme with https; it does not prescribe an HTTP status code for that internal substitution, since no HTTP exchange occurs for it. Section 7.2's suggestion of status code 301 addresses ordinary server-side redirect behavior, not this internal client-side rewrite. Confidence: high · Verified: RFC 6797 §8.3 — URI Loading and Port Mapping

So the reguła jest blunt: HSTS robi nie zastępować twój serwer-side 301s. The 301 jest co wyszukiwarki używać to zrozum protokół move i to consolidate signals (301 i other permanent redirects don’t cause a loss in PageRank, per Google). The przeglądarka-tylko internal upgrade jest a użytkownik-experience i security warstwa on top. You need oba, doing różny jobs:

  • 301 (serwer-side): dla crawlers, indeksowanie, i link equity.
  • Internal 307-style upgrade (przeglądarka-side, z HSTS): dla returning humans i SSL-stripping protection — the dokładny status representation varies by client/narzędzie.

dowolny poradnik że tells you HSTS “handles the redirect so you can drop your 301” jest błędny in a way że będzie quietly cost you.

HSTS preload: the near-permanent version

max-age protects returning visitors, ale it ma a bootstrap problem: a pierwszy-time visitor who ma nigdy received twój header jest nadal exposed on że initial żądanie. Preload solves it by hardcoding twój domain do the przeglądarka’s źródło itself, so the przeglądarka knows you’re HTTPS-tylko przed it ma ever connected.

You opt in at hstspreload.org. The requirements są dokładny:

  1. “Serve a valid certificate.”
  2. “Redirect from HTTP to HTTPS on the same host, if you are listening on port 80.”
  3. “Serve all subdomains over HTTPS” — w tym w szczególności the www subdomain if a DNS record exists.
  4. On the base domain’s HTTPS odpowiedź, an HSTS header gdzie “the max-age must be at least 31536000 seconds (1 year),” “the includeSubDomains directive must be specified,” i “the preload directive must be specified.” (hstspreload.org)

że’s why the two-year przykład above (max-age=63072000; includeSubDomains; preload) jest the shape people submit — note te są the dokładny submission requirements as opublikowany by hstspreload.org; treat them as the current bar, nie a permanent constant, i re-sprawdź live strona przed you submit.

It pomaga to zachować four distinct states straight, since people conflate them constantly:

Stateco’s actually prawdziwy
Token presenttwój header obejmuje preload. ten jest a flag tylko — it robi nothing by itself i doesn’t put you on dowolny lista.
Eligibletwój witryna meets wszystkie four hstspreload.org requirements above (cert, redirect, subdomains, header shape). nadal nie on the lista.
Submitted / pendingYou’ve submitted at hstspreload.org i it’s queued dla inclusion in an upcoming przeglądarka release. nie yet enforced dla rzeczywisty użytkownicy.
Actually listedThe domain jest baked do a given przeglądarka’s shipped build. Enforcement tylko exists dla użytkownicy on że build — rollout isn’t instant lub universal w całym przeglądarki.

Removal runs the same four states in reverse, i just as slowly: removing the preload directive z twój header makes you eligible dla the removal form, then submission jest pending, i the domain stays enforced dla dowolny użytkownik on a przeglądarka build że nadal ships it — until że build cycles out.

Now the part że turns preload do a one-way door. z the submission witryna itself: “Be aware that inclusion in the preload list cannot easily be undone. Domains can be removed, but it takes months for a change to reach users with a Chrome update and we cannot make guarantees about other browsers.” (hstspreload.org). i jego own advice: “Don’t request inclusion unless you’re sure that you can support HTTPS for your entire site and all its subdomains in the long term.”

Practical tłumaczenie: preload jest a genuinely great security posture, ale if you ever need to serve anything — a legacy subdomain, an acquired marka, an internal narzędzie — ponad plain HTTP again, you’re stuck waiting on przeglądarka release cycles to reach każdy użytkownik. Kinsta’s poradnik puts the operational reality plainly: it może być a difficult i time-consuming proces to get twój domain removed. Treat preload as permanent.

Why HSTS jest designed to hurt gdy things break

HSTS’s strictness jest nie a bug — it’s the entire security guarantee. web.dev spells out the tradeoff: “Clients that have listed your site as a known HSTS Host are likely to hard-fail if your site ever has an error in its TLS configuration, (such as an expired certificate). HSTS is explicitly designed this way to ensure that network attackers can’t trick clients into accessing the site without HTTPS.” (web.dev).

The conclusion Google draws jest the zdanie I’d tattoo on anyone o to flip ten on: “Don’t enable HSTS until you’re certain your site operation is robust enough to avoid ever deploying HTTPS with certificate validation errors.” (web.dev).

“Hard-fail” means exactly że: no “proceed anyway” link, no click-przez. On a normal HTTPS strona, an expired cert throws a scary interstitial że a determined użytkownik może bypass. On an HSTS host, the przeglądarka refuses outright. So the awaria mode of a missed certificate renewal changes kategoria — z “traffic dips because people are scared off” to “the site is unreachable for every returning visitor.”

rzeczywisty-world lockout scenarios

The ways HSTS bites w praktyce almost zawsze trace back to includeSubDomains lub preload getting ahead of twój rzeczywisty HTTPS coverage:

  • The forgotten subdomain. You ustawić includeSubDomains on example.com, ale legacy.example.com (an old app, a status strona, a vendor narzędzie) tylko speaks HTTP lub ma a cert że doesn’t cover it. każdy przeglądarka że saw the header now refuses to load że subdomain. Nothing changed on że serwer — the polityka reached down i broke it.
  • The wildcard-cert gap. A *.example.com wildcard covers foo.example.com ale nie foo.bar.example.com (a wildcard jest one DNS label deep). If a deeper subdomain relies on HTTP lub a mismatched cert, includeSubDomains locks it out.
  • The expired cert on an HSTS host. Renewal automation fails, the cert lapses, i zamiast a bypassable ostrzeżenie you get a witryna że’s down dla everyone whose przeglądarka remembers twój polityka — until you get a prawidłowy cert back i they reconnect i receive a fresh secure odpowiedź. There jest no faster override.
  • Preload regret. You preloaded, then a firma need forces an HTTP-tylko service poniżej the domain. Rolling że back jest two oddzielny, non-instant jobs, nie one: serving max-age=0 ponad HTTPS tylko clears the learned polityka dla clients że reconnect przed ich old max-age by’ve expired anyway, podczas gdy getting the domain out of the preload lista jest a distinct submission że nadal takes przeglądarka release cycles — months — to reach użytkownicy, independent of anything you change on twój serwer.
  • Local dev / staging collisions. Preloading example.com z includeSubDomains może make dev.example.com lub a localhost-style internal host poniżej the same apex refuse HTTP, breaking local przepływy pracy in surprising ways.

None of te są powody to avoid HSTS. They’re powody to stage it: short max-age pierwszy, dodawać includeSubDomains tylko po auditing każdy subdomain, i reserve preload dla gdy you’re certain.

HSTS jest nie a ranking play (i doesn’t touch canonicalization)

To być jasny on the SEO framing: HSTS jest nie a ranking signal. HTTPS itself jest a deliberately tiny one — Google called it a “very lightweight signal” affecting fewer than 1% of zapytania — i HSTS jest a warstwa on top of HTTPS, nie a oddzielny ranking input. It również doesn’t directly control canonicalization lub indeksowanie. Google’s own documentation jest więcej specific than a flat “doesn’t matter,” though: Google prefers HTTPS as canonical ponad an equivalent HTTP strona except gdy there’s an nieprawidłowy certificate, insecure strona dependencies, an HTTPS strona że redirects to HTTP, lub an HTTP rel="canonical" znacznik (Google: consolidating duplicate URLs). HSTS cannot fix lub override dowolny of że. It’s a przeglądarka-side polityka z no influence on Google’s canonicalization logic — a bad certificate lub a broken redirect chain może nadal push Google toward an HTTP canonical regardless of co twój HSTS header says. Canonicalization jest driven by twój 301s, twój certificate, twój rel="canonical", i twój linki wewnętrzne — HSTS earns jego place dla security, użytkownik trust, i closing the SSL-stripping gap — robić it dla tamte powody, zachować twój 301s i certificate genuinely solid, i you’ll nigdy see HSTS itself on a rankings raport either way.

If you’re running the broader HTTP→HTTPS move, HSTS jest the ostatni thing you switch on, nie the pierwszy — it belongs po the migration ma settled, as part of the wider migracja witryny discipline.

Add an expert note

Pin an expert quote

New person? Create their unclaimed profile at /admin/experts/ → Pin a quote first.