Can use .htaccess to redirect http connections to https?

Need to connect all users only for https connection, Can I redirect the http connections to https using htaccess,

Someone can help me please?

KR

I would rather do that in the Apache configuration files than in .htaccess

in the http configuration, place

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [L,R=301,QSA]

In the https configuration, set that the browser permanently stores the HTTPS connection

Header set Strict-Transport-Security “max-age=15780000”

1 Like