1. Change your main WordPress URLs to HTTPS
You can change your WordPress main URLs to HTTPS in the following two ways.
We recommend the first one, as it is the easiest and the most secure. However, you may need to use the second one, in case the URLs are initially set in wp-config.php.
a. From the WordPress admin, select Settings >> General and change the two URLs from http://example.com to https://example.com.
b. Alternatively, through the wp-config.php file we add the following lines.
define('WP_HOME','https://example.com');
define('WP_SITEURL','https://example.com');
2. Add redirect from HTTP to HTTPS
You can add the redirect in the following two ways.
In case you host your website in Plesk, we recommend the first one.
a. Through Plesk we select Hosting & DNS and after that Hosting.
Activate the option Permanent SEO-safe 301 redirect from HTTP to HTTPS and then select Apply and OK.
b. Alternatively, we add the following rules to the .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
3. Replacement of mixed content
The replacement of mixed content can be done either through a plugin, such as Better Search Replace , either through the use of SSH and the use of the WP CLI.
With the following actions we basically replace all domain URLs that start with http to https.
In any case, we recommend that before starting the replacement, you make a backup of your database, so that you have a backup copy.
You could create a backup using Plesk's exportÂ
a. Fixed mixed content using the plugin Better Search Replace
a1. Installation and activation of the plugin Better Search Replace from the WordPress admin by selecting Plugins from the Plugins admin >>New Plugin.
a2. Then select Tools >> Better Search Replace to display the plugin settings.
From the Search/Replace tab, perform the following actions.
In the Search for field, enter the http format: http://example.com.
In the Replace with field, enter the https format: https://example.com.
In the Select tables field, select all the tables by pressing Ctrl+a in the field.
Enable the Replace GUIDs field.
We disable the Run as dry run option so that it does not run in test mode.
Finally, click on Run Search/Replace to run the plugin.
b. Alternatively you can fix the mixed content using the WP CLI.
In case you have SSH access to your account and are familiar with using linux commands, you can run Search And Replace through the WP CLI.
b1. WP CLI is installed using the following commands.
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
alias wp='~/wp-cli.phar'
b2. Replacing the URLs is done by running the following command. Where example.com you will need to enter your domain.
wp search-replace 'http://example.com 'https://example.com'
c. You can check the changes from the page below whynopadlock.com
Before proceeding with a check, you will first need to clear the cache memory from any caching plugin you may have installed. If the above tool no longer shows you mixed content, but you continue to receive a warning in your browser, you will need to clear your browser's cache as well.
In case you continue to have mixed content, it means that there are URLs that are either generated by a plugin or your theme that needs an upgrade or the URLs are written manually in the code and you should locate the relevant files and replace them.
Also, there is the possibility that the mixed content is generated by some links pointing to an external source and is in the database, and you will need to re-run the Search And Replace based on the domain of the external source.
If the external source does not support https, there is nothing you can do and you should either remove the relevant URLs completely, or leave them as they are with the relevant warnings.
Contact our experts, they will be happy to help!
Contact us