Skip to content

Forcing WordPress to HTTPS after installing an SSL certificate on cPanel

The full sequence to force HTTPS on a WordPress site after the SSL certificate is installed on cPanel — siteurl, .htaccess, mixed content, and HSTS.

Installing the SSL certificate is step one. WordPress doesn’t notice. It will keep serving HTTP, keep emitting HTTP-prefixed asset URLs, and keep accepting logins over plaintext. The push to HTTPS-only takes another four small changes, and the order matters.

What’s happening

cPanel via AutoSSL or Let’s Encrypt drops the certificate at /var/cpanel/ssl/installed/certs/ and binds it to the domain in Apache or LiteSpeed. The web server now serves HTTPS, but WordPress’s siteurl and home options still say http:// until you change them. Asset URLs stored in the database (post content, theme settings, plugin configs) also still say http://. The redirect at the web server level rewrites the URL, but mixed content warnings come from those stored URLs.

How to verify

wp option get siteurl
wp option get home
curl -I http://example.com
curl -I https://example.com

siteurl and home should both start with https://. The HTTP curl -I should return a 301 redirect to HTTPS. The HTTPS curl -I should return 200.

The fix

  1. Update siteurl and home:

    wp option update siteurl https://example.com
    wp option update home https://example.com
  2. Search-replace HTTP-prefixed URLs in the database. Use --dry-run first to see scope:

    wp search-replace 'http://example.com' 'https://example.com' --all-tables --skip-columns=guid --dry-run
    wp search-replace 'http://example.com' 'https://example.com' --all-tables --skip-columns=guid

    Skip guid because it’s a permanent identifier — changing it breaks feed consumers.

  3. Add the HTTPS redirect to .htaccess so any direct HTTP request gets redirected at the web server, not at WordPress. Place above the # BEGIN WordPress block:

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

    On LiteSpeed, the same .htaccess works. If the site is behind Cloudflare or another proxy that terminates TLS, also add a wp-config.php block:

    if ( ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
        $_SERVER['HTTPS'] = 'on';
    }
  4. Force the admin to HTTPS at the WordPress level:

    define( 'FORCE_SSL_ADMIN', true );
  5. Audit mixed content. Browse the homepage, a content-heavy article, and the checkout if e-commerce. Open the browser’s console and look for blocked or warning resources. Common culprits: hardcoded <img src="http://..."> in widgets, CSS url() references to HTTP assets, JavaScript that hardcodes the protocol.

  6. Once stable, add HSTS. Start with a short max-age while you confirm nothing breaks, then move to long:

    Header always set Strict-Transport-Security "max-age=300; includeSubDomains" env=HTTPS

    After a week of clean operation:

    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
  7. Submit to the HSTS preload list (hstspreload.org) only after the long max-age has been live for a week and you’re confident every subdomain is HTTPS-clean. Preload is a one-way decision — reversing it takes months.

Stack Harbor handles this kind of transition as part of enterprise WordPress work.