Skip to content

WordPress SSL: move your site to HTTPS and fix mixed content

· The AYT team · 6 min read

Man typing on a laptop at a wooden table, with a phone and notebook beside it

A WordPress site needs three things to run on HTTPS: a valid SSL certificate on the server, both addresses in Settings → General written with https://, and a 301 redirect from HTTP to HTTPS. If the browser still shows no padlock after that, you have mixed content: the page loads over HTTPS but requests images, scripts or fonts over http://. Those links usually live in the database, and a careful search and replace fixes them.

What a certificate is, what the padlock guarantees and which certificate type you need are covered separately in the guide to HTTPS and SSL. Here we stick to the WordPress side.

Before anything else: does the SSL certificate work?

Open https://yourdomain.com in a private window. If the browser shows a full-screen warning ("Your connection is not private"), the problem is the certificate on the server, not WordPress: it's missing, expired, or doesn't cover the www variant. Fix that in your hosting panel before you change anything in WordPress, or you risk locking yourself out of wp-admin.

Step 1: change the site addresses in WordPress

In wp-admin, under Settings → General, put https:// in "WordPress Address (URL)" and "Site Address (URL)", then save. WordPress logs you out and sends you to the login page on the new address.

A simpler way, since WordPress 5.7: Tools → Site Health. If the server supports HTTPS and the site still uses http://, the page shows an "Update your site to use HTTPS" button, which changes both addresses and checks that the site answers over HTTPS.

When the address changes from http://domain to https://domain (through the button or in Settings → General), WordPress also starts a replacement at display time: http:// links to its own domain in the content come out as https://. It doesn't happen if you changed the addresses in wp-config.php or directly in the database, and the links in the database stay http://. That's why the replacement in step 4 is still worth doing.

Two cases where the fields can't be edited or you can't get back in:

  • The fields are greyed out: the addresses are defined in wp-config.php with WP_HOME and WP_SITEURL. Change them there.
  • You set https://, the certificate didn't work, and now wp-admin won't open: temporarily add the right addresses to wp-config.php, or change the siteurl and home values in the wp_options table in phpMyAdmin.
define( 'WP_HOME', 'https://yourdomain.com' );
define( 'WP_SITEURL', 'https://yourdomain.com' );

Step 2: the redirect from HTTP to HTTPS

Without a redirect, old http:// links and Google results still lead to the unencrypted version. The redirect is done on the server, with a 301 code. On Apache it usually goes in .htaccess; nginx doesn't read that file (details in the guide to .htaccess on nginx), so you switch it on in your hosting panel.

Watch out for redirect loops: if the server sends visitors to HTTPS and a plugin, or Cloudflare in Flexible mode, sends them back to HTTP, the browser shows ERR_TOO_MANY_REDIRECTS. The fix is in the guide to the redirect loop, and the right Cloudflare settings are in the Cloudflare guide for WordPress.

Step 3: find the mixed content

Open a page without the padlock, press F12 and look at the Console tab. Every resource requested over HTTP shows up in a "Mixed Content" message with its exact address. Modern browsers try to load images, audio and video over HTTPS directly, but they block scripts, stylesheets and iframes requested over http://. That's why a slider or a form can stop working altogether after the switch to HTTPS.

The leftover http:// links usually come from:

  • posts and pages written before HTTPS, with images inserted on the old address;
  • widgets, menus with custom links and theme settings (logo, background image);
  • page builder data (Elementor, for example, stores its content apart from the WordPress editor);
  • theme or child theme files where someone typed an address by hand;
  • old external resources (a script, a font, an iframe) loaded over http://.

Step 4: replace the links in the database

Back up the database first. Then replace http://yourdomain.com with https://yourdomain.com in every table, and the www variant separately if you ever used it.

Don't run an UPDATE ... REPLACE() straight in SQL. WordPress and many plugins store "serialized" settings, where each string's length is written next to it; change the text without the length and the setting breaks, and widgets or theme options disappear. These tools handle that:

  • WP-CLI, if you have command-line access: wp search-replace 'http://yourdomain.com' 'https://yourdomain.com' --skip-columns=guid --dry-run, then the same command without --dry-run;
  • a search and replace plugin such as Better Search Replace;
  • your hosting panel's search and replace, where it has one.

Leave the guid column in wp_posts alone: it's an identifier, not a link, and feed readers use it to recognise posts they've already shown. After the replacement, clear the site's cache and, if you use Elementor, regenerate its CSS files from its settings.

Step 5: what the database doesn't fix

Addresses typed into theme files can be found in a code editor, or after downloading the theme, by searching for http://. Change them to https:// or, for your own domain, to relative addresses. An external resource with no HTTPS version at all has to be replaced or removed.

Plugins that fix mixed content on the fly, such as SSL Insecure Content Fixer, rewrite links every time a page is displayed. As a stopgap they help, but the wrong links stay in the database and the server does extra work on every request. Really Simple Security (formerly Really Simple SSL) handles the redirect and HTTPS settings, but its mixed content scanner is Pro only.

Step 6: check the whole site

Go through the home page, a post, a page with a form and, for a shop, the cart and checkout, with the console open. Once no "Mixed Content" message appears, you can deactivate the on-the-fly fixer plugin if you used one.

Frequently asked questions

Why does the home page have a padlock but my posts don't?

Because each page loads its own images and scripts. Old posts usually have images inserted on http://, and the home page doesn't. The replacement in step 4 fixes them all at once.

Do I need to keep the SSL plugin once I'm done?

No, as long as the server does the redirect and the database links are replaced. One plugin fewer means one update fewer.

HTTPS for WordPress on AYT hosting

On AYT WordPress hosting, the Let's Encrypt certificate is issued and renewed automatically for the domain and www (plus mail and webmail). In the panel's domain list you switch on "Force HTTPS Redirect", and you pick the www or bare-domain version under "Preferred address", so you don't need a plugin for that.

The SSL/TLS Status page in the AYT panel, with the domains' certificates

For leftover http:// links, the WordPress Toolkit has a database search and replace, and the daily backups give you a way back if something goes wrong.

More articles

All articles