1

Here's a unique situation. I have three websites. All assets are stored at the domain of the first site: domain.com/files/*

The first two sites run completely over SSL. No problem. The third site needs to have the option to load either over SSL or non-SSL. This is entirely thanks to the authoritarian governments of countries like China, which may block a site, no matter the content, if it can only load over SSL.

In my config.php, I have this:

'@assetBaseUrl' => 'https://site1.domain.org/files'

If I change this to exclude https://, Craft does not create proper URLs for images and files. I also tried //site1.domain.org, but that doesn't work either.

Is there some setting I can use for @assetBaseUrl that will work across the board?

2

You could try something like '@assetBaseUrl' => $_SERVER['HTTPS'] ? 'https://site1.domain.org/files' : 'http://site1.domain.org/files' which checks for a secure request.

1
  • That did the trick, thanks so much!
    – 4midori
    Sep 25 '20 at 3:53

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.