Skip to content

Mixed content after SSL on cPanel: find and fix http://

Fix mixed content warnings after enabling SSL on a cPanel site by finding every http:// reference the page still loads and correcting it where it is written. The steps work for any PHP site and include a full WordPress section.

You installed an SSL certificate on your cPanel account, and now the padlock shows a warning, the layout looks unstyled, or a few images are gone. The browser console prints “Mixed Content: The page at … was loaded over HTTPS, but requested an insecure …” once for each broken file. The certificate works fine. The page still asks for some of its files over plain http://, and the browser refuses or rewrites those requests. Find each reference, trace it to the place that writes it, and change it there to https://.

What you’ll accomplish

  • Read the console and tell files the browser blocked from files it quietly upgraded.
  • List every http:// reference in the served HTML and in your account’s files with curl and grep.
  • Fix the stored site address and the database without breaking WordPress serialized data.
  • Turn on cPanel’s HTTPS redirect and purge the caches that still hold the old pages.
  • Decide when a Content Security Policy (CSP) header helps and when it hides the problem.

Prerequisites

  • A valid certificate on the domain. Run curl -sI https://example.com/ and expect an HTTP/2 200 or HTTP/1.1 200 line with no certificate error. If curl reports SSL certificate problem, fix the certificate first with AutoSSL failure triage.
  • Shell access to the cPanel account, through SSH or Advanced » Terminal in cPanel.
  • For WordPress, WP-CLI (the WordPress command-line tool). Run wp --info from the site folder; it should print a WP-CLI version line.
  • A fresh database backup. Use cPanel Files » Backup, or wp db export on WordPress.
  • Replace example.com with your domain and <cpanel-user> with your account name in every command.

How it works

Your browser fetches the HTML page over HTTPS, then reads it and requests every stylesheet, script, font, image and frame it names. Each of those requests has its own scheme. If the HTML names http://example.com/style.css, the browser is being asked to fetch part of a secure page over an unencrypted connection.

Browsers sort these requests into two groups. Active content can change what the page does: scripts, stylesheets, fonts, iframes and fetch calls. Anyone tampering with an unencrypted connection could rewrite the checkout form through one of them, so the browser blocks the request outright. Passive content can only be displayed: images, audio and video. Current Chrome and Firefox retry those over https:// on their own and load them if the server answers. When the upgrade fails, the file goes missing.

That split explains the odd symptoms. A blocked stylesheet leaves the page unstyled, while upgraded images look fine and hide the bad URL in your content. Older browsers can show broken images that your own browser loads without complaint. Read the console, not only the padlock.

On a cPanel account the http:// strings come from a few places. The application’s base address setting generates most links. Content stored in the database keeps whatever URL was typed when it was written. Theme and template files can hardcode addresses. Page builders write CSS files to disk that keep old URLs until you regenerate them. Third-party embeds point at hosts you do not control.

One HTTPS page requesting four resources over http://, showing where each URL comes from and that the stylesheet is blocked while images are upgraded or go missing

The MDN page on mixed content lists exactly which request types fall in each group.

Step-by-step

  1. Read the console on a broken page. Open the page, press F12, choose the Console tab and reload. Each violation names the page and the insecure file.

    Example output:

    Mixed Content: The page at 'https://example.com/shop/' was loaded over HTTPS, but requested an insecure stylesheet 'http://example.com/wp-content/themes/shopfront/style.css'. This request has been blocked; the content must be served over HTTPS.
    Mixed Content: The page at 'https://example.com/shop/' was loaded over HTTPS, but requested an insecure element 'http://example.com/wp-content/uploads/2025/03/banner.jpg'. This request was automatically upgraded to HTTPS, For more information see https://blog.chromium.org/2019/10/no-more-mixed-messages-about-https.html

    “has been blocked” marks active content, and that is what breaks the page. “automatically upgraded” marks passive content that loaded anyway. Fix both, because the upgraded ones fail on other browsers. A clean console with a broken page points to a different fault, such as a redirect loop.

  2. List the insecure references in the served HTML. The console shows only what one page load hit. curl shows every http:// link the server sends.

    curl -s https://example.com/ | grep -oE '(src|href|srcset|action)="http://[^"]+"' | sort | uniq -c | sort -rn | head -20

    Example output:

         14 src="http://example.com/wp-content/uploads/2025/03/banner.jpg"
          6 href="http://example.com/wp-content/themes/shopfront/style.css"
          2 src="http://badges.trustpartner.example/seal.js"

    No output means the HTML is clean for that page. Then check the stylesheets it loads, because url(http://...) inside a CSS file never shows in the HTML. Swap in a stylesheet URL from the page source:

    curl -s https://example.com/wp-content/uploads/elementor/css/post-42.css | grep -oE 'url\(["'\'']?http://[^)"'\'']+' | sort -u

    Any line printed is a background image or font that the CSS file still requests over HTTP.

  3. Check the base address your application stores. Every PHP application keeps one setting it uses to build its own links. If that setting still says http://, the application writes http:// into every page. Common places on cPanel:

    • WordPress: the siteurl and home options (WordPress steps follow below).
    • Joomla: $live_site in configuration.php. An empty value is fine; Joomla then follows the request.
    • Drupal: $base_url in sites/default/settings.php, when it is set.
    • Laravel: APP_URL in .env.
    • OpenCart: HTTP_SERVER in config.php and admin/config.php.
    grep -rnE "live_site|base_url|APP_URL|HTTP_SERVER" ~/public_html/configuration.php ~/public_html/sites/default/settings.php ~/public_html/.env ~/public_html/config.php 2>/dev/null

    Example output:

    /home/<cpanel-user>/public_html/config.php:3:define('HTTP_SERVER', 'http://example.com/');

    Change any http:// value you find to https:// and save the file. No output means none of these files exists or none sets a base address.

  4. Search your files for hardcoded URLs. Theme templates, headers and custom JavaScript often carry a full address typed years ago.

    grep -rnI --include='*.php' --include='*.html' --include='*.css' --include='*.js' 'http://' ~/public_html | grep -vE 'w3\.org|schema\.org|xmlns' | head -40

    Example output:

    /home/<cpanel-user>/public_html/wp-content/themes/shopfront/header.php:18:  <img src="http://example.com/wp-content/uploads/logo.png" alt="">

    Change your own domain’s links to https://, or to a relative path such as /wp-content/uploads/logo.png. Leave w3.org and schema.org addresses alone. They are namespace names that the browser never fetches. Skip third-party plugin and core folders here, since an update overwrites your edits; fix those through settings instead.

  5. Turn on cPanel’s HTTPS redirect. Visitors who still reach the http:// version get no protection at all. In cPanel, open Domains » Domains and switch on Force HTTPS Redirect for the domain. The toggle stays greyed out until the domain has a valid certificate. Confirm the result:

    curl -sI http://example.com/ | grep -iE '^(HTTP|location)'

    Example output:

    HTTP/1.1 301 Moved Permanently
    Location: https://example.com/

    A 200 means the redirect is not active. A 301 that points back to http:// means a rule in .htaccess or the application fights the toggle; see fixing too many redirects.

  6. Replace or remove third-party assets with no HTTPS. For each outside host in your list, test the secure version:

    curl -sI https://badges.trustpartner.example/seal.js | head -1

    An HTTP/2 200 line means you change the link to https:// and move on. A connection error or a certificate error means that host cannot serve a secure page. Download a copy into your own site if the licence allows, switch providers, or delete the embed. No browser setting lets your visitors load it safely.

WordPress on cPanel

WordPress builds links from two options and stores full URLs inside posts, widgets, plugin settings and page-builder data. The steps below cover the cPanel side of that cleanup. Run them from the site folder, usually ~/public_html.

  1. Back up the database.

    wp db export ~/pre-https-$(date +%F).sql

    Expect Success: Exported to '/home/<cpanel-user>/pre-https-2026-10-21.sql'. Stop if this fails; every step below changes data.

  2. Set the site address. These two options decide how WordPress writes every internal link.

    wp option get home
    wp option get siteurl

    If either prints an http:// address, update both:

    wp option update home 'https://example.com'
    wp option update siteurl 'https://example.com'

    Expect Success: Updated 'home' option. and the same for siteurl. “Value passed for ‘home’ option is unchanged” means it was already right. If wp-config.php defines WP_HOME or WP_SITEURL, those constants override the database; edit them there instead.

  3. Measure what is stored in the database.

    wp db query "SELECT COUNT(*) FROM wp_posts WHERE post_content LIKE '%http://example.com%'"
    wp db query "SELECT option_name FROM wp_options WHERE option_value LIKE '%http://example.com%'"

    A count above zero, or any option names listed, means stored content still holds old links. Option names often belong to the theme or a plugin, such as a logo setting or a payment gateway endpoint. If your table prefix differs from wp_, wp db prefix prints it.

  4. Dry-run the rewrite across every table.

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

    Example output:

    +------------------+-----------------------+--------------+------+
    | Table            | Column                | Replacements | Type |
    +------------------+-----------------------+--------------+------+
    | wp_options       | option_value          | 9            | PHP  |
    | wp_postmeta      | meta_value            | 213          | PHP  |
    | wp_posts         | post_content          | 87           | SQL  |
    +------------------+-----------------------+--------------+------+
    Success: 309 replacements to be made.

    The real output lists every column, including those with zero replacements. --skip-columns=guid leaves each post’s permanent identifier alone, because feed readers use it to recognise items they already showed. “0 replacements” means the stored URL differs, often a www. version; rerun with that form. The search-replace reference documents every flag.

  5. Run it for real. Remove --dry-run from the same command. Expect Success: Made 309 replacements. with your own count.

    Never do this with a raw SQL REPLACE(). Plugins save settings as PHP serialized strings, which record each value’s length in bytes, for example s:27:"http://example.com/logo.png";. Adding the s makes the string 28 bytes long, but SQL leaves the 27 in place. PHP then refuses to read the value, and the theme quietly falls back to its defaults. WP-CLI unpacks each value, replaces the text and writes the correct length back.

  6. Regenerate page-builder CSS. Elementor and similar builders write CSS files under wp-content/uploads/ that keep old URLs after the database is fixed.

    wp elementor flush-css

    Expect a Success: line. Without WP-CLI, use Elementor » Tools » General and click Regenerate Files & Data (older versions say Regenerate CSS & Data). Other builders have a similar button in their own settings.

  7. Check plugin and theme settings. The option names from step 3 point to plugins that store addresses. Read one to see what it holds:

    wp option get theme_mods_shopfront --format=json | grep -o 'http://[^"]*'

    Any address printed after the rewrite is a plugin writing http:// back from its own code or a remote API. Update it in that plugin’s settings page.

  8. Purge every cache. Flush the object cache, then the page cache plugin and any content delivery network (CDN).

    wp cache flush

    Expect Success: The cache was flushed. Then use the purge button in LiteSpeed Cache, WP Rocket or W3 Total Cache, whichever you run. Until each layer is cleared, visitors can receive HTML generated before the fix.

If a WordPress site still shows http:// links after all of this, the WordPress mixed content deep dive covers uploads metadata, report-only policies and the rarer hiding places.

Validate it works

  • Repeat the curl command from step 2 on the home page and on two or three busy pages. It should print nothing.
  • Open those pages with the console open and reload. No “Mixed Content” lines should appear.
  • On a shop, test the cart and checkout pages too. Payment forms often load scripts from extra hosts.
  • Check the padlock in a private window, so no cached copy hides the result.

Troubleshooting

  • Only some pages still warn. Those pages are served from a cache built before the fix. Purge the page cache and CDN again, then retest with curl.
  • The site loops between http and https after the redirect. An .htaccess rule or a plugin is redirecting back. Turn off one redirect source at a time until a single rule remains.
  • Warnings start right after you put Cloudflare in front. The origin may be detecting the wrong scheme. Follow mixed content behind Cloudflare instead.
  • Theme settings vanished after an earlier fix. Someone ran a SQL REPLACE() and broke serialized values. Restore the backup, then use wp search-replace.
  • A URL comes back after every rewrite. A plugin generates it at runtime. Search the plugin’s folder with the grep from step 4 and update its settings, or ask its developer.

When this is the wrong approach

A header such as Content-Security-Policy: upgrade-insecure-requests tells the browser to request every http:// file over https://. It can steady a site while you finish the cleanup, but it does nothing for older browsers or hosts with no HTTPS. It also hides the links you still need to fix. Remove it once the console is clean. The same goes for plugins that rewrite links on the fly.

If curl reports a certificate error, mixed content is not your problem yet; fix the certificate first. If the warnings appeared after moving behind a proxy or CDN, start with the scheme detection on that path, not the database. And for a domain change, where the hostname differs as well as the scheme, search-replace after a domain change is the better fit.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.