On this page
Automatically upgrade HTTP links to HTTPS when you control the destination and have verified that HTTPS works for the relevant host, paths, and users. Treat links to other sites differently: an HTTPS version may not exist or may not serve the same content.
This guide explains how to choose between changing links, redirecting requests, and using HSTS—and how to check a migration without mistaking one successful response for a secure site.
Key Takeaways
- Change your own links to HTTPS after checking the destination. Do not blindly rewrite links to third-party sites.
- Redirect HTTP requests at your server or edge so old links and bookmarks reach the HTTPS version. A redirect cannot protect data already sent in the initial HTTP request.
- HSTS tells supporting browsers to use HTTPS for future requests to a host. It is not a substitute for securing the first visit or fixing mixed content.
- Browser HTTPS-upgrade features vary by browser and configuration. Do not rely on them as your migration strategy.
- Test certificates, paths, redirects, subdomains, and page resources separately. An HTTPS homepage returning
200is only one check.
Decide which links to upgrade
| Destination | Recommended approach |
|---|---|
| A host and path you control, with HTTPS working | Update links, forms, and resource URLs to HTTPS; also redirect old HTTP URLs. |
| Your host, but HTTPS support is incomplete | Fix certificates, routing, and dependencies before rewriting links or enforcing HSTS. |
| A third-party destination | Check that the HTTPS URL works and serves the intended content. Otherwise, leave it unchanged or replace it with a suitable secure destination. |
| A service that does not support HTTPS | Do not assume changing http:// to https:// will work. Upgrade, replace, or isolate the service; avoid sending sensitive information over HTTP. |
Test important paths and query-driven workflows, not just the domain's homepage. HTTPS may terminate at a different server, require authentication, or return a different application. For links you publish, verify that changing the scheme preserves the intended destination and behavior.
This article could not consult current browser documentation or the HSTS specification in this environment. Check current browser-vendor guidance and RFC 6797 before deployment, particularly for browser defaults and policy behavior.
Advertisement
Redirects, browser upgrades, and HSTS are different
Site-level redirects
Configure your web server, load balancer, or CDN to respond to HTTP requests with a redirect to the equivalent HTTPS URL. Preserve the path and query string unless a deliberate migration requires otherwise. Choose one canonical HTTPS host and avoid redirect loops or unnecessary chains.
A permanent redirect such as 301 or 308 is appropriate once the destination is stable. Test client behavior before changing endpoints that accept form submissions or API writes: redirect handling, especially for methods and request bodies, can differ by status code and client. A temporary redirect can be useful while validating a migration.
The first request still reaches the server over HTTP. Its URL, headers, and any submitted body may be exposed or modified in transit before the redirect arrives. Serve forms with HTTPS action URLs, use HTTPS for API clients from the outset, and avoid placing secrets in URLs. Redirects do not retroactively protect an HTTP submission.
Browser HTTPS-upgrade behavior
Some browsers or user settings attempt HTTPS before HTTP, including for certain navigations. The exact behavior and fallback depend on the browser, version, settings, and request. A failed HTTPS attempt may produce a warning or allow an HTTP fallback in some circumstances; do not assume either outcome for every visitor.
These features are useful safeguards, but they do not update your links or guarantee that all clients—including scripts and older integrations—use HTTPS. Verify the browsers and configurations your audience actually uses.
HSTS
HTTP Strict Transport Security (HSTS) is a policy delivered in a Strict-Transport-Security response header over valid HTTPS. Once a supporting browser has learned the policy, it upgrades later HTTP requests for that host before sending them. A cached policy also makes certificate errors harder for users to bypass, so certificate reliability matters.
HSTS differs from a server redirect: the browser can upgrade a request without first contacting the HTTP endpoint. However, a normal first visit made over HTTP is not protected by a policy the browser has not learned. Preloading can address that first-visit gap for participating browsers, but has a much larger operational commitment.
Start with a short policy on an HTTPS response, for example:
Strict-Transport-Security: max-age=300
Increase the duration after monitoring. Add includeSubDomains only after auditing every affected subdomain, including future and less-visible hosts. HSTS applies to web requests, not as a general security policy for non-HTTP protocols.
To remove a learned policy, the affected host must send max-age=0 over valid HTTPS. A child host cannot remove a parent policy that covers it through includeSubDomains. Previously cached policies remain in effect until they expire or are removed successfully; preload removal has its own separate process and can take longer. Do not enable preloading until you understand those consequences and the current browser requirements.
Advertisement
Test both endpoints and the page's resources
Use a terminal with curl and replace www.example.com with a host you own or are authorized to test. The examples are diagnostic commands, not a substitute for a browser test. They have not been executed in this environment.
-
Inspect the HTTP response without following redirects:
curl -sS -D - -o /dev/null 'http://www.example.com/account?view=profile'Check the status and
Locationheader. For a redirect, the destination should be the intended HTTPS host and retain the relevant path and query. Avoid using real secrets in test URLs: they can appear in logs and terminal history. -
Inspect the HTTPS endpoint directly:
curl -sS -D - -o /dev/null 'https://www.example.com/account?view=profile'Confirm the expected status, application behavior, and headers. Do not disable certificate verification to make a failing test pass. A TLS error needs investigation, such as a wrong hostname, expired certificate, or incomplete certificate chain.
-
Follow the HTTP redirect chain and print the final URL and status:
curl -sS -L --max-redirs 10 -o /dev/null \ -w 'Final URL: %{url_effective}\nFinal status: %{http_code}\n' \ 'http://www.example.com/account?view=profile'Confirm that the final URL is HTTPS and that the response is the expected page—not an error page, unexpected login flow, or different service. Inspect intermediate responses separately when diagnosing a chain. Test write operations in an authorized staging environment with non-sensitive data and the actual client behavior.
-
Open representative HTTPS pages in a browser. Use developer tools to inspect the network requests and console for mixed-content warnings, blocked resources, failed redirects, and certificate problems. Exercise login, forms, API calls, images, scripts, stylesheets, embeds, and downloads as applicable.
-
Repeat for relevant subdomains, alternate hostnames, ports, paths, and user flows. Check HSTS headers on HTTPS responses and test policy changes in a controlled browser profile; cached HSTS can make it difficult to observe the behavior of a first-time visitor.
An HTTPS response confirms neither that every linked resource uses HTTPS nor that every page and subdomain is configured correctly. Some insecure resources may be blocked, upgraded, or handled differently by different browsers. Fix their URLs or dependencies rather than treating a clean homepage response as proof of completeness.
Common Mistakes
- Rewriting every external HTTP link. The HTTPS endpoint may be unavailable or unrelated. Verify it first.
- Enabling
includeSubDomainstoo early. An overlooked subdomain without a valid certificate can become inaccessible to browsers that have cached the policy. - Assuming HSTS protects the first HTTP visit. It generally needs a previously learned policy or applicable preload coverage.
- Testing only the homepage. Authentication, redirects, APIs, and third-party resources can fail independently.
- Using a redirect to secure an HTTP form submission. The initial submission can already have exposed its contents.
- Ignoring mixed content. An HTTPS document can still reference insecure resources, which browsers may block or otherwise handle differently.
Best Practices
- Inventory domains, subdomains, certificates, HTTP entry points, and dependencies. Include integrations and services that cannot yet use HTTPS.
- Deploy valid certificates and HTTPS routing first. Update first-party links, resource URLs, form actions, and API clients, then add HTTP redirects.
- Check mixed content and real workflows in supported browsers. Consider the
upgrade-insecure-requestsContent Security Policy directive only after testing: it can request upgrades of insecure resources, but a resource without working HTTPS can fail to load. It is not a replacement for correcting source URLs. - Review cookies used by HTTPS sessions. Set the
Secureattribute where appropriate, alongside other relevant cookie protections, and test login and logout behavior. - Introduce HSTS gradually, monitor certificate and application failures, and have a rollback plan. Treat
includeSubDomainsand preloading as separate, deliberate decisions. - Continue serving the HTTP redirect for old links where feasible, and monitor failures without logging sensitive query strings or request bodies unnecessarily.
Conclusion
Upgrade links you control once their HTTPS destinations and workflows are ready; verify third-party destinations individually. Redirects support old URLs, while HSTS and browser features add different layers of protection. Roll them out only after checking the hosts, certificates, and resources they affect.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.