How to force SSL or HTTPS with .htaccess?

It is possible to enforce SSL (HTTPS) using `.htaccess`, but first, ensure that `.htaccess` is not among the hidden files. The `.htaccess` file is typically located in the public_html directory of the site. If your website is in a subdirectory, the `.htaccess` file should be placed in the corresponding subdirectory. You can create or edit the `.htaccess` file via FTP or by using the file manager available in cPanel.

.htaccess is Hidden

By default, the `.htaccess` file is hidden. To view hidden files in the cPanel file manager, follow these steps: 1 - Log in to your cPanel account 2 - Navigate to the File Manager.

3 - Click on the Settings button in the top-right corner. 4 - In the Preferences window, check the option Show Hidden Files.

5 - Confirm by clicking the Save button. Now you can view all hidden files (including `.htaccess`) in the File Manager.

.htaccess is Not Hidden

If `.htaccess` is already visible, simply click on **Edit** and add the following rules to your website's `.htaccess` file to enforce HTTPS:

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

Video Tutorial