RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Using the above the error goes away, but automatic redirection doesn’t happen. I need to manually enter https to go to the secured site or else it opens me the unsecured version.
@Magnus Using cloudflare would be a good option as AFAIK it allows SSL on subdomains too but the drawback would be of a shared SSL. So I was looking for an option to enforce SSL on the main domain and subdomains. But since SSL on subdomains is not available on subdomains on infinityfree, hence I was looking to use Letsencrypt SSL and force redirect to https for the main domain using htaccess.
I do understand that. Normally, you should be able to add the rule to the .htaccess file, but I don‘t know what is going wrong with your implementation of it.
@Magnus For me only on one device it is being served. Other devices both http and https are being served when requested manually. And is clouflare ssl available for subdomains?
@Magnus Exactly, and it’s happening inspite of me having the .htaccess file with the above code. It would be great to receive some solution from someone, even from @Admin.
@Admin I had removed the .htaccess as it wasn’t working and then I moved on to try cloudflare. The site is currently redirecting to https but am not sure whether its the cloudflare or letsencrypt.
In the screenshot, you can see multiple references to Cloudflare. So it’s quite clear that you’re connecting through Cloudflare with Cloudflare’s certificate.