How to Force HTTPS on Your Website
To ensure visitors always use a secure connection (HTTPS), follow these steps:
Method 1: Using .htaccess (Apache Servers)
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Method 2: Using cPanel Redirects
- Log in to cPanel.
- Go to Domains > Redirects.
- Create a permanent 301 redirect from
http://yourdomain.com
tohttps://yourdomain.com
.
Method 3: Cloudflare Page Rules
If using Cloudflare, set a Page Rule to always use HTTPS:
- Go to Cloudflare dashboard.
- Navigate to Page Rules.
- Create a rule for
http://*yourdomain.com/*
to Always Use HTTPS.