3

I have a theme and am loading CSS in the traditional way, through the theme.info file, as follows:

stylesheets[all][] = css/style.min.css

However, my clients site uses HTTPS. And every 3rd or 4th load for some reason Drupal tries to load all my files via HTTP rather than HTTPS, causing all the stylesheets/js/images not to load.

Is there any way to force Drupal to use HTTPS on assets while maintaining using the theme.info file to load them?

  • Is it pure SSL? Or SSL/Non-SSL mix mode? Do you use securepages module? – Beebee Jul 24 '13 at 14:37
  • That could be a caching issue where a client requesting a page over HTTPS gets a cached copy that was generated over HTTP and thus has HTTP links in it. I'm afraid I can't recommend an exact solution because it depends on the caching engine being used. – jamix Apr 30 '14 at 14:40
  • The standard Drupal page cache is keyed on the full url, i.e. the http and https versions of the page are different, so this wouldn't normally be an issue. If this is the issue, then it's likely because you have something in front of drupal that converts the https to http. If that's the case, they you'll want to be consistent about anonymous page access to your site, i.e. force all urls to be http or https. – Alan Dixon Aug 31 '15 at 13:53
4

For a Drupal 7 site using Cloudflare CDN and a Bootstrap theme, this worked for me: Set the base URL in your settings.php file, without including http:// or https://.

$base_url = '//my.domain.name';

For another Drupal 7 site with a different theme, just removing $base_url worked. In both cases, I needed the site to work with secure URLs and without.

0

One option is to use AdvAgg as this will generate different aggregate filenames for http and https. If the issue is the cache then advagg will not fix it though.

0

You might need to set the base URL in the settings.php file, specifying the URL scheme.

$base_url = 'https://my.domain.name';

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.