How to force a website to use https by htaccess settings?
Posted on In QAI would like my site to be accessed by https only. How to force a website to use https by htaccess settings by redirecting http requests to the corresponding https ones?
You can check the method of redirecting http to https at:
https://www.systutorials.com/qa/1033/how-to-redirect-http-to-https-in-apache-with-mod_rewrite
If you would like to have a 301 redirect, you can use the following .htaccess file:
# force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]