How to Force HTTPS with .htaccess in cPanel
Forcing HTTPS ensures that all traffic to your website is encrypted, improving security and user trust. You can easily set this up by adding a rule to your .htaccess
file in cPanel. Follow these steps:
Step 1: Log in to cPanel
- Begin by logging into your cPanel account.
Step 2: Open the File Manager
- In the Files section of cPanel, click on File Manager.

Step 3: Locate the .htaccess File
- In the File Manager, navigate to the directory where your website is installed, usually the public_html folder.
- Make sure Show Hidden Files (dotfiles) is enabled in File Manager, as the
.htaccess
file is hidden by default. - If there is no
.htaccess
file, you can create one by clicking + File in the File Manager and naming it.htaccess
.

Step 4: Edit the .htaccess File
- Right-click on the
.htaccess
file and choose Edit. - A text editor will open. In the editor, add the following code at the top of the file:
apacheCopy codeRewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Step 5: Save the Changes
- After adding the code, click Save Changes at the top-right of the editor.
Step 6: Test Your Website
- Open your website in a browser and try to access it using
http://
. You should be automatically redirected to the HTTPS version of the site.
Was this article helpful?
YesNo