After you have added this text to your .htaccess file, save it.
You can test if it was successful through entering the site url in your browser.
.htaccess is a dot file, these files are hidden by default. To access the file you will first need to enable viewing of hidden or dot files within the settings area of your chosen panel or FTP software.
For example, in cPanel hidden files are enabled by clicking the settings cog.
Forcing HTTPs in cPanel
If you have cPanel you can choose to use the AutoSSL feature which will automatically install an SSL certificate and enable forced HTTPs.
Firstly, login to your cPanel control panel, navigating to “SSL/TLS Status” in the Security section.
From here you can select the domain you’d like to install an SSL on.
Finally, Run AutoSSL sit back and relax whilst it runs.
When it completes successfully the page will update with a success notification.
cPanel will then request a certificate from the issuing authority.
If successful, it will be visible in AutoSSL.
Forcing HTTPs in Plesk
If you have Plesk you can avoid manual modifications of .htaccess.
Firstly, login to Plesk control panel and click Websites & Domains in the left sidebar.
From here, choose the domain to configure and click Hosting Settings
Select SSL/TLS support and Permanent SEO-safe 301 redirect from HTTP to HTTPS checkboxes under Security
Select corresponding SSL certificate from the Certificate drop-down list
Finally, Confirm the changes by clicking the OK button