How to force SSL using .htaccess on a Linux server

The code below helps website users to visit the HTTPS version of a website.

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteEngine On
RewriteCond %{HTTP_HOST} ^marioseijo\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.marioseijo.com/$1 [R=301,L]

Simply replace the reference ‘marioseijo.com’ with your own domain name, and save the file on your server.