How to redirect all WordPress links to HTTPS via .htaccess

How to redirect all WordPress links to HTTPS via .htaccess

If you got to the point where you have already installed the SSL certificate, changes the links in the database (here is a complete tutorial about migrating WordPress to https) and WordPress is still not redirecting everything to https (or you need to redirect the old links to the new https links for google), you can make a 301 redirect to the https URLs from .htaccess by adding the following lines just before </IfModule>

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Note: the L parameter says it’s the last redirect line, so that’s why it needs to be the last thing befoore the </IfModule>