Force HTTPS on .htaccess but only on production
snippet in htaccess

Force HTTPS on .htaccess but only on production

user1600

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]