How to redirect HTTP to HTTPs via .htaccess file

Question: How to redirect website from HTTP to HTTPs?

Answer: To permanently redirect website from HTTP to HTTPs you need to create .htaccess file in website's folder with the following content:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Also Read