Apache Redirect for Canonical Domain
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule (.*) https://www.example.com$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Found this useful? Everything here is free and stays that way. If it saved you an afternoon, you can buy me a coffee.