+91 92 888 888 64 LOG IN
SSL Certificates & HTTPS Security Updated Nov 18, 2026 3 views
Fast AMP Version

How to Automatically Force HTTP to Secure HTTPS Using .htaccess

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.

Was this article helpful?

Related Topics: force https htaccess redirect http to https 301 redirect ssl cpanel htaccess secure redirect rewrite

More in SSL Certificates & HTTPS Security

View All in Category →

Still have questions?

Our technical support team is online 24/7 on WhatsApp to guide you step-by-step.

Chat with a Specialist