Force HTTPS on .htaccess but only on production
I want the snippet above to work only when I use it on production, e.g
example.com
)
You can restrict your rule to only target example.com
using a rewrite condition:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]