Thu. Oct 17th, 2019

Wpgio Online Services

The Consultant in Bayawan

Force HTTPS Redirect on WordPress websites via plugin or htaccess edit

4 min read
Force HTTPS Redirect on WordPress websites via plugin or htaccess edit

This tutorial will talk about how you can force an http url to https. This means that you can make your website secure and have the installation of SSL to be effective.

How to Force HTTPS Redirect on WordPress websites via plugin or htaccess edit???

Some of the SSL certificate are free and you can see them in your hosting provider. If they offer a free SSL then it will be a very easy job. Others also like WpEngine like my clients use, the SSL is provided by them and even if you have a paid SSL for your domain. You will still need to follow the steps on how to set-up in their hosting.

Are you also trying to fix SEO for technical issues on your website?
Check out my tutorial: SEO AUDIT CHECKLIST

HOW TO HAVE “HTTPS” ON MY SITE?

So this is the first question that will going to have in your mind. This is basically a purchased SSL certificate or a free SSL certificate. If you purchase an SSL then you need to activate it in one of your domain name. And after that you will check if it will going to be accessible in https://yoursite.com.

So once you have installed or activated the SSL certificate on your domain you need to force every link to be secure “https” so that you will not going to have mix content on your site and it will be not secure.

STEPS TO FORCE HTTPS REDIRECT ON YOUR SITE:

FORCE HTTPS REDIRECT ON WORDPRESS WEBSITES VIA PLUGIN OR HTACCESS EDIT

 

STEP 1 : Download Really Simple SSL

Download and install Really Simple SSL plugin for your website and make sure that the SSL is already activated on your namecheap or any domain providers that you used.

Force HTTPS Redirect on WordPress websites via plugin or htaccess edit

STEP 2 : Run and Activate the Plugin

After activating the plugin you need to check in the Setting then in the SSL dropdown. After clicking that options you will have an activate SSL button. You can press it and activate. It will going to log you out of the site. Go ahead and login back. And check everything if all is fix then you are good to go. Proceed in step 3 if you still has problem.

Force HTTPS Redirect on WordPress websites via plugin or htaccess edit 7

STEP 3 : Install Better Search Replace Plugin

In this step we will going to use a different plugin and the name is Better Search Replace. This has a very easy steps also and this plugin will change the database of your site.

Force HTTPS Redirect on WordPress websites via plugin or htaccess edit 8

STEP 4 : Activate the plugin and Locate at the back-end

After activating the plugin, go to Tools then look for better search replace option.

Force HTTPS Redirect on WordPress websites via plugin or htaccess edit 9

STEP 5 : Steps to Configure in the plugin

So if you are in the setting of better search replace you will saw this image bellow so (1) will be http://wpgio.com/ which means the url is not sercure it is in “http”. (2) second box you will going to provide the url of the https://www.wpgio.com/ which means that it is now secure… SO first you put what the plugin will search for and second you will put the url that will going to replace the URL. (3) this is a box which you will going to highlight everything in the tables that will going to be updated.

(4) this is the option in which you will going to check the process if how much tables will going to be updated. If this is uncheck then the tables will be change.

(5) this is the button to fire the process.

Force HTTPS Redirect on WordPress websites via plugin or htaccess edit 10

Forcing HTTPS Using the .htaccess

Ok So your website is not in made in WordPress, Lets say you manually coded your website. And you Installed SSL on your site.

So in order for your visitors to visit them in a secure URL we are going to paste this code in our .htaccess file.

If you can’t locate the .htaccess then you just create them.

Redirect All Web Traffic

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect Only Specified Domain

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

If this doesn’t work, try removing the first two lines.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

Make sure to replace example\.com with the domain name you’re trying force to https. Additionally, you need to replace www.example.com with your actual domain name.

Check more resources here on force https redirect if your website doesn’t use WordPress:
https://www.inmotionhosting.com/support/website/ssl/how-to-force-https-using-the-htaccess-file

If you have problem using this codes and encountered a problem. All you have to do is remove the code and lets review it.

Cheers,
Mr.G

Leave a Reply

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