1

I'm trying to put my entire website under https connexion, but my css and js are not loaded. I don't know why.

I had this code to the htaccess at the root of the website :

  # Force HTTPS and WWW
  RewriteCond %{HTTP:HTTPS} !on
  RewriteRule (.*) https://%{SERVER_NAME}/$1 [QSA,L,R=301]

And didn't touch anything else. If it's relevant, I'm using a hosting from online.net (french provider).

2
1

So after researches, everything work now and here is my configuration :

I putted this code into my sites/default/setting.php file :

$conf['https'] = FALSE;
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
  $base_url = 'https://www.efficient-network.eu';
}
else {
  $base_url = 'http://www.efficient-network.eu';
}
$_SERVER['HTTPS'] = 'On'; 

And needed to add a custom module to load every line in <head> </head> with https :

function https_process_html(&$vars)
{
    foreach (array('head', 'styles', 'scripts') as $replace) {
        if (!isset($vars[$replace])) {
            continue;
        }

        $vars[$replace] = preg_replace('/(src|href|@import )(url\(|=)(")http(s?):/', '$1$2$3', $vars[$replace]);
    }
}

I don't know if it's the proper method, but it works.

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.