How to Force 301 WordPress Redirects when Switching from HTTP to HTTPS

1 min read

Topics: blog, SEO

Closed brass padlock resting on a folded paper arrow, the cover image for How to Force 301 WordPress Redirects when Switching from HTTP to HTTPS

Switching your WordPress site from HTTP to HTTPS by installing an SSL certificate can seem daunting. Once you follow the instructions, it isn’t so bad. One frustration I encountered after installing many SSL certificates using WordPress was the 302 redirect it defaults to when forcing an HTTPS in .htaccess. I couldn’t find the right code until I stumbled upon the right trick.

Place this .htaccess code at the very top line of the file in order to force WordPress to 301 redirect to HTTPS:


RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

Keep reading

All SEO articles