Search code examples
phpwordpress.htaccesssslmixed-content

SSL fixed content , why is not returning site_url() , in https scheme


In my WordPress site, I'm using another WordPress in sub-folder like: https://www.mywpexample.com/wp-newsite

I have done SSL for my Site, but suddenly showing there console Mixed content https not loading errors , and not loading any assets (css/js/actions) in site https://www.mywpexample.com/wp-newsite.

I have tried to echo site_url() its return's http://www.mywpexample.com/wp-newsite but in the database and wordpress general setting I have already:

WordPress Address (URL) -> https://www.mywpexample.com/wp-newsite

Site Address (URL) -> https://www.mywpexample.com/wp-newsite

And on the wp-config file:

define('WP_SITEURL', 'https://www.mywpexample.com/wp-newsite' );
define('WP_HOME', 'https://www.mywpexample.com/wp-newsite' );
define('ABSOLUTE_URL', 'www.mywpexample.com/wp-newsite');

If trying to add SSL options like in wp-config:

define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL', true)
define('FORCE_SSL_LOGIN', true)

After Site Breaking and browser showing errors for TOO_MANY_REDIRECTS. For now, I have got this solution for front-end replace all http --> to https.. in root index.php

<?php
ob_start();
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

//and these lines also 
$output = ob_get_contents();
ob_end_clean();

$output = str_replace(array("https://", "http://"), "//", $output);
echo str_replace('http:\/\/', "\/\/", $output);

But Need a better solution which , work for all environments (wp-admin, wp-login and front-end).


Solution

  • Hey Guy's If you going this same issue . "Mixed content blocking"

    Please use the following plugin

    if using ngnix server , that's change in plugin setting according your server recommendations .enter image description here