Force WordPress to HTTPS

My host automatically creates ssl certificates for each domain that I add. I wanted my site to always go to https instead of http. I found that if you replace the current .htaccess contents, you can do just that.

This is what (currently) comes in the .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

This is what I replaced it with:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Finally, you need to change WordPress’ settings and make the change there too. In your WordPress administrator dashboard, go to Settings -> General and change both URLs to have https:// rather than http://.

It will look something like below:

Hope that helps!

-TG

Leave a Reply