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 withcurlandgrep. - 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 anHTTP/2 200orHTTP/1.1 200line with no certificate error. If curl reportsSSL 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 --infofrom the site folder; it should print aWP-CLI versionline. - A fresh database backup. Use cPanel Files » Backup, or
wp db exporton WordPress. - Replace
example.comwith 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.
The MDN page on mixed content lists exactly which request types fall in each group.
Step-by-step
-
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.
-
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 -20Example 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 -uAny line printed is a background image or font that the CSS file still requests over HTTP.
-
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 writeshttp://into every page. Common places on cPanel:- WordPress: the
siteurlandhomeoptions (WordPress steps follow below). - Joomla:
$live_siteinconfiguration.php. An empty value is fine; Joomla then follows the request. - Drupal:
$base_urlinsites/default/settings.php, when it is set. - Laravel:
APP_URLin.env. - OpenCart:
HTTP_SERVERinconfig.phpandadmin/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/nullExample output:
/home/<cpanel-user>/public_html/config.php:3:define('HTTP_SERVER', 'http://example.com/');Change any
http://value you find tohttps://and save the file. No output means none of these files exists or none sets a base address. - WordPress: the
-
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 -40Example 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. Leavew3.organdschema.orgaddresses 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. -
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
200means the redirect is not active. A301that points back tohttp://means a rule in.htaccessor the application fights the toggle; see fixing too many redirects. -
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 -1An
HTTP/2 200line means you change the link tohttps://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.
-
Back up the database.
wp db export ~/pre-https-$(date +%F).sqlExpect
Success: Exported to '/home/<cpanel-user>/pre-https-2026-10-21.sql'.Stop if this fails; every step below changes data. -
Set the site address. These two options decide how WordPress writes every internal link.
wp option get home wp option get siteurlIf 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 forsiteurl. “Value passed for ‘home’ option is unchanged” means it was already right. Ifwp-config.phpdefinesWP_HOMEorWP_SITEURL, those constants override the database; edit them there instead. -
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 prefixprints it. -
Dry-run the rewrite across every table.
wp search-replace 'http://example.com' 'https://example.com' --all-tables --skip-columns=guid --dry-runExample 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=guidleaves 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 awww.version; rerun with that form. The search-replace reference documents every flag. -
Run it for real. Remove
--dry-runfrom the same command. ExpectSuccess: 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 examples:27:"http://example.com/logo.png";. Adding thesmakes the string 28 bytes long, but SQL leaves the27in 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. -
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-cssExpect 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. -
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. -
Purge every cache. Flush the object cache, then the page cache plugin and any content delivery network (CDN).
wp cache flushExpect
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
.htaccessrule 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 usewp 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.