Home › Blog › Article

Migrating to HTTPS: Certificates, Mixed Content, Indexing

Answer first: what a correct WordPress HTTPS migration looks like in 2026

Back up files and the database, stage the change, issue a SAN certificate for both hostnames, install the full chain, force HTTPS at the edge, update WordPress home and siteurl, rewrite serialized URLs, fix mixed content, then serve one 301 hop from every http URL to its https equivalent. It is done right when curl -I shows a single 301 plus 200 over TLS, DevTools reports zero mixed content, certificate renewal succeeds in a dry run, and Google Search Console shows https URLs indexed with http URLs transferring signals. This WordPress HTTPS migration guide is written to be executed in order: prepare, step, verify, roll back.

Preparation Process: freeze, snapshot, and define the rollback line

  1. Put the site in maintenance mode on staging, record WordPress 6.8.x or current 2026 branch, PHP 8.3, MySQL or MariaDB version, web server, CDN, and active cache plugins.
  2. Take a filesystem snapshot and a logical SQL dump; store both outside the web root with a checksum manifest.
  3. Export current DNS, TLS, rewrite, CDN, and Search Console property settings so every change has an inverse.
  4. Capture a baseline crawl of up to 10,000 URLs including status, redirect chain, canonical, and rendered asset origins.
  5. Agree on the rollback trigger: any 5xx above 0.5 percent, checkout failure, or admin lockout for 10 minutes reverts immediately.
  6. Schedule the cutover inside a low-traffic window and keep the old certificate valid for at least 7 days after launch.

Preparation is not paperwork; it is what makes the later database rewrite reversible. On a typical Ubuntu 22.04 or 24.04 host running Nginx 1.24+ or Apache 2.4.58+, run the snapshot before touching DNS or certificates. If the site also changed domains, align this work with WordPress Domain Replacement: Vendor Evaluation Guide 2026 so you do not combine two redirect variables in one debugging session.

# /root/https-cutover/01-snapshot.sh
set -euo pipefail
STAMP=2026-https-$(date +%F-%H%M)
mkdir -p /root/https-cutover/$STAMP
cd /var/www/example.com
tar --exclude='wp-content/cache' -czf /root/https-cutover/$STAMP/files.tgz .
wp db export /root/https-cutover/$STAMP/db.sql --path=/var/www/example.com --allow-root
wp option get home --path=/var/www/example.com --allow-root > /root/https-cutover/$STAMP/home.txt
wp option get siteurl --path=/var/www/example.com --allow-root > /root/https-cutover/$STAMP/siteurl.txt
sha256sum /root/https-cutover/$STAMP/* > /root/https-cutover/$STAMP/SHA256
curl -sS -o /root/https-cutover/$STAMP/chain-before.txt -w '%{http_code} %{redirect_url}
' -I http://example.com/

Keep the old certificate, old vhost file, and old wp-config.php in the same directory. Rollback is a file copy plus an SQL import, not a guessing exercise. Confirm the dump restores into a scratch database before cutover; an untested backup is only a rumour.

Step 1: Issuing and renewing certificates

Use ACME with a SAN certificate covering example.com and www.example.com; wildcard certificates are useful for multisite subdomains but unnecessary for a single site. In 2026, Certbot 3.x with ECDSA P-256 keys and a 90-day Let’s Encrypt lifetime is the sane default, while an OV or EV certificate is still appropriate when procurement demands organisation validation. Issue on staging first with the dry-run endpoint, then on production with the HTTP-01 or DNS-01 challenge that matches your CDN topology. Behind Cloudflare or a load balancer, terminate TLS at the edge and also keep origin TLS so the hop is encrypted end to end.

Issue with Certbot on Nginx or Apache

# Ubuntu 24.04, Certbot 3.1+ (2026)
sudo snap install certbot --classic
sudo certbot certonly --nginx 
  -d example.com -d www.example.com 
  --key-type ecdsa --elliptic-curve secp256r1 
  --preferred-chain 'ISRG Root X1' --dry-run
sudo certbot certonly --nginx 
  -d example.com -d www.example.com 
  --key-type ecdsa --elliptic-curve secp256r1 
  --preferred-chain 'ISRG Root X1' --agree-tos -m ops@example.com
sudo ls -l /etc/letsencrypt/live/example.com/{fullchain.pem,privkey.pem}
sudo nginx -t && sudo systemctl reload nginx

For DNS-01 on a proxied host, use certbot -a dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini with credentials mode 0600. Install fullchain.pem, never cert.pem alone; a missing intermediate is the most common cause of “works in Chrome, fails in curl or older Android”. Add HSTS only after 7 clean days: Strict-Transport-Security: max-age=300 first, then raise to 31536000; includeSubDomains. Do not submit preload until every subdomain is ready.

Renewal that you can prove

Certbot 3.x installs a systemd timer, not a cron file. Verify with systemctl list-timers 'certbot*', then force a controlled dry run and inspect the deployment hook. If your edge uses a separate certificate, add a hook that uploads the new chain and reloads the CDN API; a renewed origin certificate that the edge never sees still expires from the visitor’s point of view.

sudo certbot renew --dry-run --deploy-hook 'systemctl reload nginx'
sudo systemctl list-timers 'certbot*' --no-pager
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null 
  | openssl x509 -noout -dates -issuer -ext subjectAltName
curl -sS -I https://example.com/ | grep -i 'strict-transport|HTTP/'

Verification: expiry must be roughly 90 days out, SAN must list both hostnames, and SSL Labs or testssl.sh must report a complete chain. Pitfalls include rate limits after repeated failed dry runs, CAA records blocking the CA, clock drift breaking OCSP, and a CDN “Full” mode that is not “Full (strict)”. Rollback: restore the previous /etc/letsencrypt/live/example.com symlink target and the saved vhost, reload Nginx, and remove the HSTS header immediately; browsers that already cached a long max-age will keep forcing HTTPS, which is why the staged 300-second header matters.

Get a Quote

Email + requirement + budget range — we reply with a quote within 24 hours.

Change the canonical address first, then rewrite stored URLs. WordPress stores URLs in options, post content, postmeta, termmeta, and widget text; some of that data is PHP-serialized, so a plain SQL REPLACE corrupts string lengths and silently breaks page builders. WP-CLI search-replace unserializes and reserializes correctly, and its --dry-run output tells you exactly how many tables and rows will change before anything is written. Run it on staging, then production, with --all-tables-with-prefix so custom tables are included, but exclude log and transient rows where practical.

cd /var/www/example.com
wp option update home 'https://example.com' --allow-root
wp option update siteurl 'https://example.com' --allow-root
wp search-replace 'http://example.com' 'https://example.com' 
  --all-tables-with-prefix --precise --recurse-objects 
  --skip-columns=guid --dry-run --report-changed-only --allow-root
wp search-replace 'http://example.com' 'https://example.com' 
  --all-tables-with-prefix --precise --recurse-objects 
  --skip-columns=guid --report-changed-only --allow-root
wp cache flush --allow-root
wp rewrite flush --hard --allow-root

Keep guid unchanged: it is an identifier, not a fetchable URL, and changing it makes feed readers treat every post as new. Hardcoded http:// in wp-config.php, theme functions.php, child theme CSS, and mu-plugins is not in the database; grep the filesystem and fix those files under version control. If WP_HOME or WP_SITEURL constants are defined, they override the database, so update the constants or the option changes will appear to do nothing.

grep -RIn --exclude-dir=cache --exclude='*.min.js' 
  'http://example.com' /var/www/example.com/wp-content /var/www/example.com/wp-config.php
# wp-config.php, only if constants are used
define('WP_HOME', 'https://example.com');
define('WP_SITEURL', 'https://example.com');
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
    $_SERVER['HTTPS'] = 'on';
}

The forwarded-proto block fixes the infinite-redirect loop that appears behind a reverse proxy when PHP still thinks the request is plain HTTP. Verify with wp option get home, wp eval 'echo home_url("/wp-content/uploads/2026/01/logo.png");', and a rendered page source containing no internal http://. For broader host moves, the sequence in How to Migrate a WordPress Website: Vendor Guide for 2026 maps cleanly onto this database pass. Rollback: import db.sql into the live database, restore wp-config.php, flush object cache, and confirm the admin login works before re-enabling traffic.

Step 3: Hunting mixed content

Mixed content is any subresource still fetched over HTTP on an HTTPS document: images, scripts, styles, fonts, iframes, srcset entries, CSS url() values, lazy-load data-src, JSON-LD image fields, and third-party pixels. Browsers block active content such as scripts and upgrade or warn on passive content, so the symptom is usually a broken slider, missing icon font, or a console full of Mixed Content warnings rather than a total outage. Hunt it in three layers: database, rendered DOM, and network trace.

Database and content layer

After the bulk replace, query for protocol-relative and escaped variants that the first pass missed. Serialized JSON inside postmeta often contains http://, and page builders may store URL-encoded values. Use WP-CLI for a second targeted pass with --dry-run, then inspect remaining matches manually rather than blanket-replacing every http:// string, which would damage external links and saved code samples.

wp db query "SELECT ID, post_title FROM wp_posts WHERE post_content LIKE '%http://%' AND post_status='publish' LIMIT 50;" --allow-root
wp search-replace 'http://example.com' 'https://example.com' 
  --all-tables-with-prefix --precise --dry-run --allow-root
wp search-replace '//example.com/wp-content' 'https://example.com/wp-content' 
  --all-tables-with-prefix --precise --dry-run --allow-root

Rendered DOM and network layer

Open Chrome DevTools 2026, use the Security panel and Console filter mixed, then run a DOM query in the Console to list every insecure attribute. Pair that with a headless crawl so templates that only appear on a single archive or checkout page are covered. Add a temporary Content-Security-Policy report-only header in staging to collect violations from real traffic without breaking pages.

// Chrome DevTools console, on the rendered page
[...document.querySelectorAll('[src^="http://"],[href^="http://"],[srcset*="http://"'],'[data-src^="http://"']')]
  .map(el => el.tagName + ' ' + (el.src || el.href || el.getAttribute('srcset') || el.dataset.src));
# Nginx, staging only, report-only
add_header Content-Security-Policy-Report-Only 
  'default-src https: data: blob:; upgrade-insecure-requests; report-uri /csp-report' always;

# Headless crawl with Node 22 + puppeteer 24 (2026)
node -e "const p=require('puppeteer');(async()=>{const b=await p.launch();const pg=await b.newPage();pg.on('request',r=>{if(r.url().startsWith('http://'))console.log('INSECURE',r.url())});await pg.goto('https://example.com/',{waitUntil:'networkidle2'});await b.close()})()"

upgrade-insecure-requests is a safety net, not a fix: it hides the symptom while the stored URL remains wrong, and it does nothing for hosts that do not serve TLS. Fix the source, then keep the directive as defence in depth. Common pitfalls include a CDN origin set to HTTP, an iframe embed from a legacy video provider, a font loaded from an old fonts.example host, and a caching plugin that still serves a pre-cutover HTML fragment. Purge every cache layer in order: object cache, page cache, CDN, then browser cache for your own testing profile. Verify with zero console warnings, zero INSECURE lines from the crawl, and a Security panel reading “This page is secure”. Rollback mixed-content fixes by reverting only the offending theme or mu-plugin commit; do not roll back the certificate or the database rewrite for a single bad image URL.

Step 4 Process: 301s and search console

Serve one server-level 301 from every http:// URL to the exact same path and query string over https://, with no intermediate hop to www or a trailing slash. Choose one canonical hostname before writing the rule; combining http→https and non-www→www in two separate rules is the classic two-hop chain that dilutes crawl efficiency. Put the redirect in Nginx or Apache, not in a PHP plugin, so it fires before WordPress boots and works for /wp-content/uploads/* too.

# /etc/nginx/sites-available/example.com.conf
server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;
}
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name www.example.com;
    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    return 301 https://example.com$request_uri;
}
server {
    listen 443 ssl;
    http2 on;
    server_name example.com;
    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    root /var/www/example.com;
    # WordPress rules follow
}
# Apache .htaccess, above the WordPress block
RewriteEngine On
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/%{REQUEST_URI} [R=301,L,NE]

Use $request_uri rather than a rewritten URI so encoded characters and query parameters survive. Verify every representative URL family, including a paginated archive, an attachment page, a feed, a REST endpoint, and a checkout query string.

for u in '/' '/?s=ssl' '/wp-login.php' '/feed/' '/wp-json/wp/v2/posts' '/wp-content/uploads/2026/01/logo.png'; do
  curl -sS -o /dev/null -w "%{url_effective} %{http_code} %{redirect_url} %{num_redirects}n" -L "http://example.com$u"
done
curl -sS https://example.com/ | grep -o '<link rel="canonical"[^>]*>'

Expect 301 then 200, num_redirects 1, canonical pointing to https://example.com/..., and identical query strings. Then update the indexing surface in Google Search Console: keep the old Domain property if you already have one, otherwise add and verify the https://example.com URL-prefix property, submit the HTTPS sitemap, and use URL Inspection on 10 representative URLs to request indexing. Confirm sitemap_index.xml itself contains only HTTPS <loc> values; Yoast SEO 24.x, Rank Math 1.0.24x, and WordPress core 6.8+ all derive sitemap URLs from home, so a stale object cache can publish HTTP locs for hours. Update robots.txt sitemap line, canonical tags, Open Graph og:url, JSON-LD @id, hreflang pairs, and any hardcoded analytics or ad-tag allowlists.

Watch Search Console Coverage and Page Indexing reports for 14 to 28 days in 2026: http URLs should move to “Page with redirect” or “Alternate page with proper canonical tag”, while https URLs become “Indexed”. A temporary dip in impressions is normal; a sustained 404 spike is not. Do not disavow, remove old URLs with the Removals tool, or submit a change-of-address in Search Console: this is a protocol change, not a domain move. The WordPress.org HTTPS support documentation is worth keeping open for admin-specific constants, and the force_ssl_admin() reference explains the admin-side enforcement hook if you need it in a mu-plugin. For teams coordinating this alongside a host change, our WordPress Site Migration service follows the same snapshot, cutover, and verification gate described here.

Rollback for redirects: restore the saved vhost or .htaccess, reload, and immediately confirm http://example.com/ returns 200 again. If HSTS was already raised to a year, rollback cannot make browsers accept HTTP on that hostname, so keep the old certificate alive and fix forward instead. In Search Console, resubmit the previous sitemap and leave both properties verified; never delete the old property during the observation window.

Verification gate and rollback runbook

Run the gate before declaring success, and keep the output attached to the change ticket. Every line is binary: pass or fail, with a named owner. If any line fails, execute the rollback runbook in reverse order of the steps above rather than patching live under traffic.

CheckCommand or signalPass condition
TLS chainopenssl s_client -servername example.comComplete chain, SAN has both hosts, ~90 days remaining
Renewalcertbot renew --dry-run plus timerSuccess, timer next run under 30 days
Redirectcurl -IL on 6 URL familiesExactly one 301, then 200, query preserved
Stored URLswp search-replace ... --dry-runZero replacements remaining for the old origin
Mixed contentDevTools Console plus headless request listenerZero warnings, zero insecure requests
Cache layersObject, page, CDN purge logsNo pre-cutover HTML served from any edge POP
IndexingSearch Console URL Inspection and sitemapHTTPS locs, no 404 spike, indexing requests accepted
Business pathsLogin, checkout, form, REST, webhookAll complete with no loop or CORS regression

Rollback runbook: (1) restore the saved vhost and reload the web server; (2) restore wp-config.php and the theme or mu-plugin commit; (3) import db.sql with wp db import; (4) flush object and page caches and purge the CDN; (5) reinstall the previous certificate symlink if it was replaced; (6) re-run the same six curl checks against HTTP; (7) resubmit the prior sitemap and post a short incident note. Keep the staging clone alive for 7 days so you can reproduce any Search Console anomaly without touching production again. More field notes like this are collected on the technical column index.

Frequently asked questions

Do I need a separate Search Console property for HTTPS?

No if you already use a verified Domain property; it covers all protocols and subdomains. If you only have an http:// URL-prefix property, add the https:// URL-prefix property, submit the HTTPS sitemap, and keep both verified for at least 28 days in 2026.

Is a plugin-based redirect or a database find-replace plugin enough?

No for production. Server-level 301s fire before PHP and cover uploads, feeds, and REST; WP-CLI search-replace handles serialized data safely. Plugins are acceptable as a temporary bridge on hosts without vhost access, but add latency and fail when a caching layer serves a stale page.

Why does the admin still redirect-loop after the cutover?

PHP sees plain HTTP behind a proxy, so WordPress keeps redirecting to HTTPS. Trust only the proxy header you actually control, set $_SERVER['HTTPS'] = 'on' from HTTP_X_FORWARDED_PROTO, purge page cache, and confirm wp option get home matches the canonical hostname exactly.

Action checklist

  • Snapshot files, SQL, options, vhost, and DNS; prove the SQL dump restores into a scratch database.
  • Issue a SAN ECDSA certificate, install fullchain.pem, and confirm the renewal timer plus dry run.
  • Run WP-CLI search-replace with --dry-run first, skip guid, then grep the filesystem for hardcoded HTTP.
  • Enforce one-hop 301s, purge every cache layer, and clear mixed content from DOM, CSS, srcset, and embeds.
  • Submit the HTTPS sitemap, inspect 10 URLs in Search Console, and monitor indexing for 14 to 28 days before enabling long HSTS.

Need a second pair of hands on a production cutover? Our team handles certificates, serialized rewrites, redirect maps, and post-launch indexing checks. See website migration or browse all services to book a pre-migration audit.

“,”faq”:[{“question”:”Do I need a separate Search Console property for HTTPS?”,”answer”:”No if you already use a verified Domain property; it covers all protocols and subdomains. If you only have an http:// URL-prefix property, add the https:// URL-prefix property, submit the HTTPS sitemap, and keep both verified for at least 28 days in 2026.”},{“question”:”Is a plugin-based redirect or a database find-replace plugin enough?”,”answer”:”No for production. Server-level 301s fire before PHP and cover uploads, feeds, and REST; WP-CLI search-replace handles serialized data safely. Plugins are acceptable only as a temporary bridge on hosts without vhost access.”},{“question”:”Why does the admin still redirect-loop after the cutover?”,”answer”:”PHP sees plain HTTP behind a proxy, so WordPress keeps redirecting to HTTPS. Trust only the proxy header you control, set $_SERVER[‘HTTPS’] = ‘on’ from HTTP_X_FORWARDED_PROTO, purge page cache, and confirm wp option get home matches the canonical hostname exactly.”}],”cover”:”Modern flat technical illustration of a browser window shifting from a pale grey insecure rail to a vivid teal secure rail, padlock shield, certificate chain nodes, redirect arrows, clean console panel and small search-index grid, isometric depth, crisp geometric shapes, no text, letters, numbers, logos or watermarks.

References & further reading

Need WordPress Development?

Free proposal and quote within 24 hours — we serve clients worldwide.

QQ