The Problem
Accessing my site over https (the only protocol allowed) I get the content, but none of the CSS, images etc.
Drupal is creating pages in response to https requests that include http links to these resources, but it should be using https.
What I've done
I have copied a site to a dev server. The site loads and basically works fine - I can log in etc. It's just that all the links drupal generates are http. The site I've copied it from also runs over https. The site does not exist on http (it would just get a Forbidden error). I've drush cc all
.
So Apache's working - I can access the site. .htaccess
is working (clean urls work, for example).
I'm using SNI to access the site because the server has other vhosts too, but I'm only accessing the site using the latest Firefox (and as it's a dev site and I'm the only dev, nobody else will use it).
I've done this dozens of times and am quite stumped! Why does Drupal not notice that the request came over https?
The fix
Turns out that .htaccess
has this to say:
/* Base URL (optional). If Drupal is generating incorrect URLs on your site, which could be in HTML headers (links to CSS and JS files) or visible links on pages (such as in menus), uncomment the Base URL statement below (remove the leading hash sign) and fill in the absolute URL to your Drupal installation.
Sure enough, putting $base_url = 'https://example.com';
fixed it.
But why is this necessary?
.htaccess
file does not have the statement you posted in it. I re-downloaded Drupal 7 and coppied the.htaccess
from there, and it also does not have this statement. What can I do? How can I make this work?.htaccess
file came from if it is different.