After installing an SSL certificate, add the following code to your .htaccess file to redirect all traffic from HTTP to HTTPS. For more on migrating your WordPress site to HTTPS.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]Make sure the code is placed at the top of your .htaccess file, before the existing WordPress rules.