Live Creation AMP Fast Page

How to Automatically Force HTTP to Secure HTTPS Using .htaccess

Category: SSL Certificates & HTTPS Security • Updated: Nov 18, 2026
Key Takeaway: A single copy-paste .htaccess snippet to automatically redirect all non-secure HTTP traffic to secure HTTPS.

Why Automatic HTTPS Redirection is Needed

Even after installing an SSL certificate, visitors typing yourdomain.com may still connect via insecure HTTP unless your web server forces an automatic 301 Permanent Redirect to the HTTPS protocol.

Step-by-Step .htaccess Configuration

  1. Log into your cPanel and open File Manager.
  2. Inside the public_html/ directory, click Settings in the top-right corner and ensure Show Hidden Files (dotfiles) is ticked.
  3. Locate the .htaccess file (create one if it does not exist) and click Edit.
  4. Add the following code block at the very top of the file:
# Force HTTPS Rewrite Rule
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Save changes and test by opening your website with http:// in a private browsing window. It will seamlessly redirect to https:// with the secure padlock active.

Chat with Support on WhatsApp