Answers.Body: <p>You could try something like <code>'@assetBaseUrl' =&gt; $_SERVER['HTTPS'] ? 'https://site1.domain.org/files' : 'http://site1.domain.org/files'</code> which checks for a secure request.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-25T03:53:42.830Z
Answers.Text: That did the trick, thanks so much!
Answers.UserDisplayName: 4midori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-22T18:52:28.630Z
Answers.LastActivityDate: 2020-09-22T18:52:28.630Z
Answers.UserDisplayName: dmatthams
Body: <p>Here's a unique situation. I have three websites. All assets are stored at the domain of the first site:
  domain.com/files/*</p>
  <p>The first two sites run completely over SSL. No problem.
  The third site needs to have the <strong>option</strong> 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.</p>
  <p>In my config.php, I have this:</p>
  <pre><code>'@assetBaseUrl' =&gt; 'https://site1.domain.org/files'
  </code></pre>
  <p>If I change this to exclude <strong>https://</strong>, Craft does not create proper URLs for images and files. I also tried <strong>//site1.domain.org</strong>, but that doesn't work either.</p>
  <p>Is there some setting I can use for @assetBaseUrl that will work across the board?</p>
  
Tags: <assets><config><ssl>
Title: Loading assets cross-domain with SSL or non-SSL option
ThreadText: # Loading assets cross-domain with SSL or non-SSL option
  
  (Asked by: username_0 on 2020-09-22)
  
  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?
  
  **Tags:** assets, config, ssl
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-09-22. Score: 2 | Accepted answer
  
  You could try something like `'@assetBaseUrl' => $_SERVER['HTTPS'] ? 'https://site1.domain.org/files' : 'http://site1.domain.org/files'` which checks for a secure request.
  
  > **Comments:**
  > **username_0**: That did the trick, thanks so much!  
  
  ---
  
  