How do I Force my Website to use SSL?

http-to-https-with-htaccess
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 M Joseph — Web Designer Kozhikode Kerala

Written by

Shopify Partner & Web Designer  ·  Kozhikode, Kerala  ·  Since 2011

Arul M Joseph is a certified Shopify Partner and freelance web designer based in Kozhikode, Kerala. Since 2011, he has built 500+ websites for small businesses and eCommerce brands across India, UAE, UK, US, and Australia. His work covers Shopify stores, WordPress websites, WooCommerce stores, and Laravel applications. arulmjoseph.com is a government-registered MSME (Udyam No: UDYAM-KL-08-0062793), verified on GoodFirms and the Shopify Partner Directory.