Are you looking for How to force SSL on your website? After installing SSL, your website enables you to surf with HTTPS. But, by default, when someone visits your website it just redirects HTTP, not HTTPS. Do not worry because it not harm to your website.
But, how you can fix it to force HTTPS on your website to look your website more secure and trusted.
Here is simple tutorial you can follow.
How to Force SSL?
Before we started, here I would like to tell you this tutorial only working on the Apache server type. Not the Nginx server type. Not sure your server running Apache or Nginx? Look tutorial on how to check Apache or Nginx run on the server.
Step 1 Login cPanel/FTP Client
First of all, please login to your cPanel. If your server not provide cPanel, you can use FTP client. For tutorial cPanel or FTP client, you can look on how to use cPanel and how to use FTP client respectively.
But in this case I will use cPanel.
Step 2 Open .Htaccess
After login to cPanel, go to your root installation WordPress file and then find the file .htaccess. If you can’t locate it, maybe your cPanel hides it.
To unhide, go to setting and tick to “Show Hidden Files (dotfiles)” then click save. If you still not find it, make sure to create a new one. No problem.
When you have .htaccess file, make sure it on editor mode because we will add some code here.
To turn on it to editor mode just right click on .htaccess file such as image below.
Note: “Setting” I have mentioned above (step 2) is located at the top right on your cPanel. If you still have a problem just drop a comment below.
Step 3 Copy & Paste Code
Here, I will separate it into several parts for specific redirection. You can choose which one you need because all of these code give you different redirection.
Copy one of the code below, and paste into it (.htaccess). When done, click the button Save Change to save what you have edited just now.
» Forcing HTTPS on All Incoming URL
The best method if you want forcing https on all incoming URL via .htaccess is using 301 redirects, which permanently redirects an old URL to a new one.
If you wish so, use this code to paste on .htaccess.
Make sure RewriteEngine On do not repeat write on .htaccess file. Keep just one only.
Usually, you need this code.
» Forcing HTTPS on a Specific Domain
This is for special case and not many use this.
Let’s say that you have two domains: http://domain1.com and http://domain2.com. Both domains access the same website, but you only want the first one to be redirected to the HTTPS url. So, you need to use the following code:
Make sure to replace domain1.com with your desire domain trying to force HTTPS on.
» Forcing HTTPS on a Specific Folder
If you wish to force HTTPS on specific folder for your website, you can do it too. However, the file should be placed in the folder that will have the HTTPS connection.
So, use this code to paste on .htaccess.
Make sure to change the folder references to the actual directory names.
Now, you have setting SSL force redirect to your domain.
I recomend after making these change, please clear cookies and cache on browser to give you best experience when try it.
If you still have problem about redirection to SSL, please drop your comment below.
I will reply it as soon as possible.
Conclusion
In this tutorial, I have shown you how to force SSL on your website. So, when someone visit to your website, it will be redirect to secure page HTTPS. As I told you before, this tutorial only working if your server using Apache.
If you like this article, then please FOLLOW our Linkedin, Twitter, YouTube, Pinterest, and Facebook. Do not forget to check our services page to upgrade your WordPress. If you find this post has an issue with copyright, outdated, or in error, please contact us to fix it.
Aneru says
nice blog
FaizAlias says
hi…thanks for stopping by here 🙂
bimbusworld says
nice job