HTTPS migrations · Practical guide
An HTTP to HTTPS redirect checklist
An HTTP to HTTPS move should preserve the page the visitor requested. Start by making HTTPS work on every supported hostname, then add the redirect and check real pages in a browser. A secure homepage alone does not establish that old deep links, assets or sign-in flows still work.
Keep the hostname, path and query during the upgrade
Suppose http://example.com/docs/install?lang=en must reach the same documentation in English over HTTPS. For an Nginx listener receiving public HTTP traffic, these named server blocks return a permanent redirect to a fixed HTTPS hostname. Replace the example names and merge the rules into the existing configuration; keep the working HTTPS server blocks.
The $request_uri variable includes the original path and query string. Do not replace it with /, or append the arguments again. Separate fixed destinations make the intended hosts explicit. This example also upgrades www to HTTPS on www; any subsequent hostname normalization belongs on that working HTTPS endpoint.
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
return 301 https://www.example.com$request_uri;
} - Make the direct HTTPS page and certificate work on example.com and www.example.com before enabling either redirect.
- Run nginx -t in the target environment, deploy through the normal reload process and trace a deep URL with a harmless query value.
- Confirm the expected Location and final content, then repeat for the www host and an asset. A homepage-only success does not complete the check.
Make every accepted HTTPS hostname work first
Check certificates for the bare hostname and www separately, including renewal and the chain presented to visitors. An HTTPS alias must complete TLS before sending its HTTP redirect. A certificate for example.com alone does not cover www.example.com, and redirecting www later cannot repair that first connection.
Record where DNS points and where TLS terminates: CDN, load balancer or origin. Keep the intended IPv4 and IPv6 listeners consistent with published DNS. Do not put an unconditional redirect on an HTTP-only origin behind a TLS-terminating proxy if HTTPS traffic is forwarded there unchanged; that can redirect the same public HTTPS URL repeatedly. Let the public edge own the upgrade or use correctly trusted scheme information.
Separate the HTTPS upgrade from other URL changes
For this migration, keep resource paths and meaningful parameters unchanged. Test encoded characters, a trailing slash and a harmless language or filter value. RedirectPath redacts query values, so compare the exact local destination when a value determines the content. A path change can be valid in a separate migration, but must be intentional and mapped.
MDN recommends upgrading HTTP to HTTPS on the same hostname before redirecting to another host, so the first host can deliver HSTS over HTTPS. For www normalization, that can mean HTTP www, then HTTPS www, then the preferred HTTPS host. This deliberate extra step is different from an accidental loop or repeated normalization.
Reference: MDN: HTTP redirection and hostname changes
Update templates and test the rendered page
Change internal links, canonical URLs, sitemap entries and any hreflang references to the intended HTTPS destinations. Remove HTTPS-to-HTTP fallbacks. Check the generated output of more than one template rather than assuming an application URL setting updates every stored link.
Open representative pages with DevTools Network and Console visible. Check scripts, styles, images, downloads and form actions for insecure dependencies. Browsers may upgrade some mixed content and block other requests; a completed document redirect does not prove the page works. Test sign-in, a form submission and an external callback that your application uses. RedirectPath does not render these journeys.
Reference: MDN: finding and fixing mixed content
Complete the release checks before extending HSTS
Test the deployed redirects with the small matrix below. Use a GET trace as well as a browser: a browser that already knows HSTS may upgrade the URL locally and never exercise the HTTP server rule. Inspect the final body; a 200 login screen is not the requested public article.
Once HTTPS and renewal work reliably, introduce HSTS on HTTPS responses with a deliberately short initial lifetime, then increase it after verification. Only add includeSubDomains after validating every affected subdomain. Preloading is a separate commitment. Browsers ignore HSTS received over HTTP; a previously learned policy does not disappear merely because you remove the header.
| Starting URL or flow | Pass condition |
|---|---|
| HTTP homepage on each accepted host | A finite route to the intended HTTPS homepage. |
| HTTP deep link with a harmless query | The required path, query value and content survive. |
| Direct HTTPS on bare and www hosts | TLS succeeds before any hostname redirect. |
| Page, asset, form and sign-in journey | Expected content loads and required actions work over HTTPS. |
Reference: MDN: HSTS behaviour and subdomain scope
Keep reading
Related guides
301 vs 302 vs 307 vs 308 redirects
Choose a redirect status with a practical decision table, then verify GET, POST, caching and the final destination.
Read guide TroubleshootingHow to find and fix redirect chains and loops
Read redirect traces, identify conflicting www or trailing-slash rules, and repair chains without losing the page, path or required query parameters.
Read guide Proxies and CDNsHow to fix redirect loops behind a proxy or CDN
Diagnose repeated HTTPS redirects behind TLS termination, check Cloudflare origin encryption, and configure trusted forwarded schemes without trusting arbitrary clients.
Read guide Browser diagnosticsHTTP redirects vs JavaScript and meta refresh
Find why a browser navigates after a 200 response, distinguish HTTP redirects from scripts and refresh, and verify the right fix.
Read guide Domain migrationsHow to check redirects during a domain migration
Map old URLs to useful new destinations, preserve important parameters and verify TLS, redirects, page content and Google Search signals.
Read guideHTTP status code reference for redirects and endpoints
Compare 301, 302, 303, 307 and 308, then interpret common endpoint errors and redirect stop reasons.
Open reference