Categories
Linux

Force your site to load https with an .htaccess file

The following forces any http request to be rewritten using https. For example, the following code forces a request to http://anytimes.cyou to load https://anytimes.cyou. It also forces directly linked resources (images, css, etc.) to use https:

Add below into  .htaccess file

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"