SSL Giving Lots Of Errors

  • Hi all,

    And thanks in advance for your help.

    I've had a client contact me saying a site I did quite a long time ago is having some issues:

    All the CSS isn't showing and there are a bunch of mixed content errors like this

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

    I think the errors have been caused by a recent SSL certificate being added (that's a guess).

    I've tried adding code to the config file:

    1. define('PERCH_SSL', true);

    And I've added the following "force_ssl" code to the start of the contact page (just this page for the moment as a test)...

    1. <?php $page = "Contact Us"; ?>
    2. <?php include('perch/runtime.php'); ?>
    3. <?php PerchSystem::force_ssl(); ?>
    4. <?php perch_layout('global.header'); ?>
    5. <div class="text_page">
    6. <div class="left_side">
    7. <div class="page_title">
    8. <h1>Contact Us</h1>...

    But this doesn't seem to change anything. Does anyone know what's going on?

    Also, here's the .htaccess file if that's helpful...

    1. RewriteEngine on
    2. RewriteCond %{HTTPS} off
    3. RewriteCond %{HTTP:X-Forwarded-SSL} !on
    4. RewriteCond %{HTTP_HOST} ^mainesurfacefinishing\.com$ [OR]
    5. RewriteCond %{HTTP_HOST} ^www\.mainesurfacefinishing\.com$
    6. RewriteRule ^(.*)$ "https\:\/\/www\.mainesurfacefinishing\.com\/$1" [R=301,L]



  • drewm

    Approved the thread.
  • Thank you Clive & hus_hmd,

    I thought I'd already set up relative links, but I was looking in the wrong place. Once I found the right code it was easy to sort:

    1. <?php define( 'SCRIPT_ROOT', '' ); ?>
    2. <link rel="stylesheet" href="<?php echo SCRIPT_ROOT; ?>css/reset.css" />
    3. <link rel="stylesheet" href="<?php echo SCRIPT_ROOT; ?>css/base.css" />

    So, I changed the SCRIPT_ROOT to and all was sorted. I just need to go through all the external links now and check those. Thanks for your help.


  • Don’t forget if you’re referencing external urls like fonts or other CDN provided content you don’t need to specify a protocol the browser will use the protocol of the page. Ex: becomes // and you won’t get mixed content issues if your protocol changes from page to page.... not that it should though ;-)