WordPress – Redirect HTTP to HTTPS

wordpress-redirect-https

In this WordPress tutorial we will learn how to redirect a WordPress powered website from HTTP to HTTPS. This means all pages of the wordpress website will open with https protocol.

Example:

https://dewcodes.com

Step 1: Install SSL Certificate

Your first step should be to install a valid SSL certificate on your website. You do not need to purchase any SSL certificate. Your hosting provider should provide you free SSL certificate and should also install on your domain name.

In case, your hosting provider is not providing you SSL certificate, you can get a free Letsencrypt SSL cerficate for your website from here.

Step 2: Change Website Address

Login to your WordPress website and navigate to:
Dashboard Settings General

Add https to WordPress Address (URL) and Site Address (URL) as shown in below image.
wordpress-https-site-name

Step 3: Add Redirect Code

Now we will redirect all non-https urls to https url.
Add following codes in .htaccess file located in public_html directory or in the WordPress root directory. These codes should be placed at the top.

1
2
3
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Done!!
Your WordPress website should now use https protocol for all pages.

Alternative Method: Using A Plugin

You can also use a WordPress plugin to redirect your website to https.
Really Simple SSL

Please note, this plugin will only redirect your website to https, it will not get you a SSL certificate, nor will install SSL certificate on your domain name.

Related Posts

Leave a Reply

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