How to force-redirect wordpress website from HTTP to HTTPS automatically
Once you have installed your SSL certificate, you will need to redirect all traffic from HTTP to HTTPS to make sure it passes through SSL certificate. There are few ways to do it:
- Edit .htaccess file in your hosting server
In order to do this, you need to open file manager of your hosting. It will work if your website is created on cPanel hosting like HTML website or wordpress or Drupal or any other CMS.
Once you have opened file manager, you will see files of your website. They will be same like you have files in your computer drive.
You need to find public_html(1) folder as shown in below image from left side and then you need to click on Settings(2) at top right side and make sure you have checked the “Show Hidden Files (dotfiles)” option. Now, you need to find .htaccess(4) file here as shown in image below. If you are not able to find it, click on create file(3) from top left side to create it. Make sure to use dot before htaccess file while creating it.
Once you have opened .htaccess file, you will need to paste below code over there to redirect website to https.
Here is the redirection code or you can generate automatically from below link:
https://www.webride.net/tools/http-to-https-redirection-script.php
RewriteEngine On
RewriteCond %{HTTP_HOST} webride\.net [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.webride.net/$1 [R,L]
Now, this code is for my website webride.net, make sure you replace webride.net with your domain name. Once you are done, save changes and refresh your website. Website will start loading with SSL certificate.
In case SSL is not working, it means SSL certificate is not installed or it is not correctly installed. you can test SSL certificate on SSL checker or why no padlock and troubleshoot accordingly by contacting SSL provider.
2. “Really simple SSL plugin”
You can download this plugin and activate it and it will work same way like what above steps did. This option will work for CMS like wordpress.
*NOTE* Make sure you either use .htaccess or plugin. If you will use both, website will throw errors like “too many redirects” etc.