WordPress Security

Fix mixed content error when activating SSL/HTTPS on your website

When we change our site from http to https, we can "suffer" a series of mishaps along the way. In this post I will explain how to fix one of the most common errors, the mixed content error, which can appear when you activate the security certificate on your site. 

Mixed content error header

If you still do not have a security certificate on your website (green padlock next to the URL), you have to get your act together and implement it as soon as possible, here is an entry explaining it to you Why should you implement HTTPS on your site?.

What is the mixed content or unsafe content error?

When we implement the security certificate and change the path of our WordPress, it may we let ourselves along the way the internal links that we have used to load our images, links between the different pages, style sheets that we are calling directly or any URL that we have placed by hand.

This error is technically known as a mixed content error, since we find URLs with HTTP and others with HTTPS.

Fixing it using the Search & Replace plugin

I always recommend doing things using as few plugins as possible, even if this means that you roll up your sleeves, I say this because I am not going to use the plugin Really Simple SSL and also to do not affect performance from our website when we can solve this in other, more effective ways.

To fix the mixed content error, we will use the plugin Search & Replace. This plugin will allow us to carry out a search in our entire database, to find those URLs that we have left with http and later replace them with https.

First of all check that the route of your WordPress is defined with https in Settings> General of your site.

mowomo website installation path

Once this theme is controlled, we install the plugin Search & Replace and we're going to Tools > Find and Replace.

Search and Replace WordPress admin

Once on the plugin page, it will tell us directly to make a backup copy of the SQL database, totally mandatory for what we are going to do next, click on the create SQL file button and in a second it will create the copy for us ready to download. Download the file and go to the Search and Replace tab. 

In the search and replace screen we will see 2 fields at first glance, the first one to insert the text that has to be searched for, the second to enter why the searched text must be replaced. Very simple!

Search and Replace

We must introduce the following, 

Search for: http://www.mydomain
Replace with: https://www.mydomain

It is important that you put the part of your domain and not just http and https because if you have external links, you cannot control that other people's websites have the certificate enabled and if they do not, the link would lead to an error.

Once this is written, in the next field "Choose tables:" select the checkbox "Choose all tables" and we will go to the last part.

There are 2 more fields with which we must operate. The first one is called “Mock” ​​and it is always activated by default.

Basically what it does is what it says, it doesn't change anything in your database, it just simulates how many tables would have to be modified.

mock button

I always recommend doing a drill before, to check that everything is correct and that we do not get out of hand directly with the database.

If we have already carried out drills or the risk simply goes away, you uncheck it. Now you can select one of the two options that will come next.

The first one "Export SQL file with changes" I use frequently when I have a copy of the same WordPress with which I am working and I want to test those changes first locally or in a test installation and check that everything works correctly.

That we still want more risk in our lives, for that they gave us the second option “Save changes to the database”. this option directly modify the data of our databasewithout any compassion.

At this point for tastes colors, but if you have backup copies and so on, there are no problems in that you save directly in the database. Click on "Search and Replace" and ready we already have our https working correctly.

Does the padlock still not appear?

You have done everything before and it still does not serve you, you are already thinking that Víctor de mowomo has deceived you. There is still one thing left that could be giving you the errors.

We have modified all the content that was in our database, but not the code of our theme. As a general rule, plugins and themes that use resources directly from the web, have a part of code that captures, so to speak, the different routes of our WordPress.

It may be the case that your theme is not using these functions, so you only have to download it, open the code and do a search of the URL of your site with http. Surely you will find some little icon or something like that that is being called directly. Once modified, everything should be correct.

As always, back up your site before doing any of this.

I hope you have been able to solve your problem with http and https and see you next week, best regards! 😀

¡Subscribe to our newsletter and receive our offers, news and discounts directly to your email!