How do I Force my Website to use SSL?

http-to-https-with-htaccess

What is htaccess ?

htaccess is a configuration file for use on web servers running the Apache Web Server software.

Forcing all website traffic to use HTTPS

Use the following code in your .htaccess file

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Forcing a specific domain to use HTTPS

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^abcd\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.xyz.com/$1 [R,L]

 

Common htaccess Rules

arul joseph: Arul M Joseph is a Shopify Partner and freelance web designer from Kerala, India. With 14+ years of experience, he creates SEO-friendly websites, e-commerce stores, and digital solutions for startups, SMEs, and global brands. His featured projects include SDE Calicut University, Revathi Kalamandir, and actor VK Sreeram’s official website. He also offers business email, domain, and hosting services.