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: https://www.mainesurfacefinishing.com/contact-us.php


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


    Code
    1. Mixed Content: The page at 'https://www.mainesurfacefinishing.com/contact-us.php' was loaded over HTTPS, but requested an insecure script 'http://www.mainesurfacefinishing.com/quform/js/jquery-1.8.3.min.js'. 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:


    Code
    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)...


    PHP
    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...


    Code
    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]


    Thanks,


    Andy

  • 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:


    PHP
    1. <?php define( 'SCRIPT_ROOT', 'http://www.mainesurfacefinishing.com/' ); ?>
    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 https://www.mainesurfacefinishing.com/ and all was sorted. I just need to go through all the external links now and check those. Thanks for your help.


    Andy

  • 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: http://cdn.jquery.com becomes //cdn.jquery.com and you won’t get mixed content issues if your protocol changes from page to page.... not that it should though ;-)