I have a PHP app on Heroku with an SSL certificate for the www version of the domain name. I need all requests (to both www and non-www) to go to via https, and I have added .htaccess to that affect. However, there are still circumstances where it's possible for a user to access the http version and I don't understand why.
Here is my .htaccess:
RewriteEngine on
RewriteCond %{HTTPS}::%{HTTP_HOST} ^off::(?:www\.)?(.+)$
RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R]
My understanding is that this should force all users to access via https://www
, but that doesn't always happen. For example, Google sometimes provides search results without the https
and the links open insecure http
instead.
Any ideas about what I'm doing wrong?