SSL htaccess and subpages

I have read all the pertinent GRAV documentation and a lot of similar posts on SSL and htaccess issues. I apologize since this topic seems common but the specific advice I found does not work and the other advice is to vague.

  1. Using this to force SSL via htaccess does not work:

    RewriteCond %{HTTP:X-Forwarded-Proto} https
    RewriteRule .* - [E=HTTPS:on]

  2. using this works:

    RewriteCond %{HTTP:X-Forwarded-Proto} !=https
    RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=302,L]

  3. however #2 gives me a 404 on any subpage or on the admin page

  4. I enable this in htaccess:

RewriteBase /

  1. #4 does not change anything

  2. I do NOT see the GRAV style 404 Not Found error page. BUt the server 404 page. And I know when I flip #2 on or off, I can see the htaccess file is indeed working. But it is weird, when I put “Test.” at the top of the htaccess file, it is ignored. So in some cases it is LIKE it is reading the htaccess file and in some cases it is NOT.

Any other suggestions?

I am using Rochen as my web host.

I setup the SSL using standard settings from Let’s Encrypt

I found that the either of the following worked:

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS}::%{HTTP_HOST} ^off::(?:www\.)?(.+)$
RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R]

The latter includes redirecting all non-www versions to the www versions.

For future reference:

https://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite#4399158