WordPress : redirect all traffic to HTTPS

You got a certificate and configured your server/hosting to serve pages on HTTPS. You’re almost there !

Here is how to make sure that all visitors use HTTPS now.

1. Configure WordPress to generate HTTPS URLs

Go to your WordPress administration interface and choose “Settings” in the menu. Make sure that “WordPress address (URL)” and “Site address (URL)” begin with “https://”.
Save the changes.

This settings ensures WordPress generates HTTPS URLs when displaying links to your pages, blog posts embedded images, etc.

2. Redirect all traffic to HTTPS

We also want to make sure that all incoming traffic ends up using HTTPS. For this we need to edit the “.htaccess” file which can be found at the root directory of your WordPress installation.

If you do not know how to access the files on your server, please ask your provider !

Edit the file and add these lines at the beginning of the file, before the “## BEGIN WORDPRESS” line :

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

Save the changes, and voilĂ !

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.