Moving WordPress HTTP to HTTPS migrate htaccess

There are loads of conflicting htaccess solutions for moving a WordPress site from HTTP to HTTPS but none of them worked for me. This was my solution for safely migrating a full site from HTTP to HTTPS. Don’t forget you will need to create a new property in Webmaster tools as Google sees the HTTPS as a new site. If you correctly 301 redirect all the HTTP links, and change your references in the database from HTTP to HTTPS, then this will work perfect:

RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Comments