Use .htaccess file settings to force redirection of the http protocol to the https protocol

To force traffic to use the HTTPS protocol, the most common method is to implement request redirection through the .htaccess file, the following is a basic description of the .htaccess file and the procedure:

.An .htaccess file is a simple text file with the name “.htaccess” that contains additional settings passed to the web server that can support some of the more complex features of a website.

If you are using a script created by someone else (including a content management system such as WordPress), you can usually find an existing .htaccess file in your website's htdocs folder; if you don't already have one, you will need to create it yourself - it is recommended that you use a file manager to create one! This is because some systems (especially Windows) do not support .htaccess files well, and a file manager can help you avoid problems during the creation process.

Once you have found or created the .htaccess file, you can edit it using a file manager, or any text editor (e.g. Notepad), by adding the following lines of code to the file:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:CF-Visitor} ! {"scheme": "https"}
RewriteRule (. *) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Source : https://forum.infinityfree.com/docs?topic=49322

en_USEnglish