force https

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 certificates are free, and you can see them in your hosting provider. If they offer a free SSL, then it will be a straightforward job. Others also like WpEngine, as 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 be 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 names. And after that, you will check if it will going to be accessible at 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 have mixed content on your site, and it will not be secure.

STEPS TO FORCE HTTPS REDIRECT ON YOUR SITE:

 

STEP 1 : Download Really Simple SSL

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

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 those options, you will have an activate SSL button. You can press it and activate it. It will be going to log you out of the site. Go ahead and login back in. And check everything. If all is fixed, then you are good to go. Proceed to step 3 if you still have a problem.

STEP 3 : Install Better Search Replace Plugin

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

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

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

STEP 5 : Steps to Configure in the plugin

So if you are in the setting of better search replace you will saw this image below so (1) would be http://wpgio.com/ which means the URL is not secure it is in “HTTP.” (2) second box, you will be going to provide the URL of 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 replace the URL. (3) this is a box in which you will be going to highlight everything in the tables that will be updated.



(4) this is the option in which you will check the process of how many tables will be updated. If this is unchecked, then the tables will be changed.

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

Forcing HTTPS Using the .htaccess

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

So for your visitors to visit them in a secure URL, we will paste this code in our .htaccess file.

If you can’t locate the .htaccess, then you 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 a problem using these codes and encountered a problem. All you have to do is remove the code, and let’s review it.

Cheers,
Mr.G

Similar Posts

Leave a Reply

Your email address will not be published.