5

I have a Joomla site that I am finishing up and now loading onto the server that will host the live site. I'm now getting the following error in the javascript console:

Mixed Content: The page at 'https://mydomain.com' was loaded over HTTPS, but requested an insecure stylesheet

A view source reveals

<base href="http://mydomain.com"

This href value appears to be set in /libraries/joomla/document/renderer/html/head.php, which calls

$document->getBase() 

to get this value. In /libraries/joomla/document/document.php, this value is set with an $options array passed to the constructor, but I cannot find where these options are set.

I had thought this value, as well as the constants JPATH_BASE, JPATH_ROOT, JPATH_SITE, etc., would be assigned whichever protocol the site uses. Am I missing a setting somewhere on the back end of the site?

I am using Joomla 3.7.2

  • Have you forced https using your Joomla global configuration, also this issue is generally due to some extension trying to load script using http, please find the css file that is loading using http, we could help you more with this information – Pratyush Oct 4 '18 at 1:04
  • Where is the CSS file being loaded from? Can you show us the code that's loading it? – Lodder Oct 4 '18 at 9:20
5

So it really is the base href value that is causing the problem. Commenting out the assignment in /libraries/joomla/document/renderer/html/head.php will do the trick.

// Generate base tag (need to happen early)
/*
$base = $document->getBase();
if (!empty($base))
{
    $buffer .= $tab . '<base href="' . $base . '" />' . $lnEnd;
}
*/

However, it would be best to actually solve the problem of assigning the correct value. I found a better solution on StackOverflow here:

https://stackoverflow.com/questions/19733229/joomla-base-href-uses-http-instead-of-https

The accepted answer to this question tells us, "there servers where $_SERVER['HTTPS'] is obviously not initialized." So the real solution is to fix the .htaccess file, or as I did, the httpd.conf file by adding the following:

<IfModule mod_env.c>
   SetEnv HTTPS on
</IfModule>

I suppose I could have kept searching before posting my question here, but by posting the answer perhaps I can save someone else the hours I spent yesterday on this problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.