2

I want to install Drupal in https, but I failed.The page is trying to open resources (css, etc) in http. How to solve this ?

enter image description here

  • 2
    That can happen because you entered the website when it was in http, and urls are stored in http so. Can you try clear caches and enter on the site in https first? – mistermoper Sep 28 '17 at 15:21
  • @OmarMohamadElHassanLopesin Yes, I've tried that. But unfortunately it didn't work – Aditya Sep 28 '17 at 15:36
2

In Drupal 7 you could set the $base_url='https://example.com'; in /sites/default/settings.php.

For Drupal 8 it looks like $base_url has been removed in favor of trusted domain patterns which are protocol agnostic. Using .htaccess rules seems to be the recommended approach.

In .htaccess below RewriteEngine on

  # Redirect to HTTPS
  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

That's from this page: https://www.drupal.org/https-information

1

You can call the CSS, javascript, and other files using '//' as a prefix to the source. This renders the files for both http and https depending on how the page was rendered.

<script src="//code.jquery.com/jquery-3.2.1.js"></script> 

Not the answer you're looking for? Browse other questions tagged or ask your own question.