How to Force HTTPS Using .htaccess
Use this code in your .htaccess file to force every page on your website to use SSL (HTTPS). This is good for SEO and it’s how Google wants every website to load now.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]This code also works but you need to put your domain name in the third line (in place of “www.yourdomain.com” – I prefer what’s above, actually):
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R=301,L]📄 Download a PDF of This Article
