Gutenberg, HTTP instead HTTPS of files address, and more interesting things

Problem: site use HTTPS protocol, but its files e.g. images use HTTP protocol. In addition, we have error in the Gutenberg editor with update content and because of that began that story.

Why a site use HTTPS protocol, but its files use HTTP?

Solution: This a story began due to the impossibility update content use Gutenberg. I opened browser console and I saw typical error "Mixed Content" for favicon. Hm, it's very strange, why favicon use HTTP protocol? I tried update all URLs in database, but without result 🙁 After a while, I finally found solution in wp-config.php.

if ( $_SERVER['SERVER_NAME'] == 'remote-sitename.com' ) {
	define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/' );
} else {
	define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/sitename/' );
}

and here is our mistake:

define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/' );

instead http:// should be https:// and correct code:

if ( $_SERVER['SERVER_NAME'] == 'remote-sitename.com' ) {
     define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/' );
 } else {
     define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/sitename/' );
 }

Leave Comment

Your email address will not be published. Required fields are marked *