Problem HTTPS wordpress, plesk

3

Good, I have a website made in wordpress.

When I put it in HTTPS I do not load the styles and it gives some problems. The error that gives me is this

  

Mixed Content: The page at ' link ' was loaded over HTTPS, but requested an insecure stylesheet ' link '. This request has been blocked; the content must be served over HTTPS.

actually gives more than one.

I have tried to access the header of the page but what I find there does not have any direct link to the styles, it has its own wordpress code.

How can I solve this problem?

Thank you.

    
asked by Pavlo B. 21.11.2017 в 10:35
source

2 answers

3

The problem is that Wordpress saves all the URL of the post and the attachments with the complete URl in the BBDD , so even if you force it from Plesk, Wordpress will always try paint what you have in BBDD .

I recommend using a replace tool so that you replace everything: http://midominio.com by https://midominio.com in all BBDD .

I recommend the following, if you unzip it in the root of Wordpress it itself takes the data of the BBDD : link

That way you will change all references from http of your domain to https and so Wordpress will already be ready to paint those URL correctly and you will not have mixed content, except that in the subject or in some plugin is put in the code itself a fuego .

If so, you will have to edit those files by hand.

As I said below (comments) something that should be done is also emptying the entire cache. Both the browser and Wordpress if it exists.

As they also say, forcing Wordpress to be low HTTPS is an option, but I do not think it's the best, because if in the BBDD or somewhere it is still referring to http you will continue to have contenido mixto , or, but, an error loading some resource.

    
answered by 21.11.2017 в 12:13
0

Everything depends on your knowledge and time you want to dedicate ::

Via plugin

This option is the simplest:

link

With tools

link

With this tool, we will upload a copy of our DB and automatically replace the previous domain (http) with the new one (https)

Via Functions.php

Another way, is to perform some function in your functions.php that replaces all the http with https in the output, but basically it will be the same as the previous plugin.

Manual

As a last resort, and a bit more entertaining is to do everything manual:

In the wordpress config:

Adjustments - General we modify both the address of Wordpress, as the address of the site.

Next, force the WP administrator to write to wp-config.php:

define('FORCE_SSL_ADMIN', true);

Now it's time to download a copy of the complete website, where we will search http: // throughout the project to locate any unsafe protocol call, here it is not about replacing everything directly, but analyzing each appearance in detail to see if you really have to modify it.

Afterwards, update the links in your DB (you will have to update the SQL code, with as many formats as you need):

UPDATE wp_posts 
SET    post_content = ( Replace (post_content, 'src="http://', 'src="//') )
WHERE  Instr(post_content, 'jpeg') > 0 
        OR Instr(post_content, 'jpg') > 0 
        OR Instr(post_content, 'gif') > 0 
        OR Instr(post_content, 'png') > 0;

In case you have single quotes:

UPDATE wp_posts 
SET   post_content = ( Replace (post_content, "src='http://", "src='//") )
WHERE  Instr(post_content, 'jpeg') > 0 
        OR Instr(post_content, 'jpg') > 0 
        OR Instr(post_content, 'gif') > 0 
        OR Instr(post_content, 'png') > 0;

If you use custom options:

UPDATE wp_postmeta 
SET meta_value=(REPLACE (meta_value, 'src="http://','src="//'));

Finally, we force HTTPS in apache:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Remarks

As you comment when you access the header template, you do not locate any direct resource load, this is because it is done through actions and hooks. You will probably find something of the style a: wp_head(); , this is the action that is responsible for generating all the content that is passed through the function files. Probably in your functions.php or maybe it is organized in another way depending on the template you use, is where you will find the calls to the resources of the website, so the way to locate the exact resources, you have to do a follow up of the code until you reach the result.

Greetings,

    
answered by 28.11.2017 в 16:10