Published Date: June 7, 2019

HTTP to HTTPS, to understand how to redirect website traffic from HTTP to HTTPS, first, we will give a brief about what is HTTP and https. Let’s start it.

You might see some websites running over HTTP and some are over HTTPS. The reason for this is the hero of the story which is the SSL certificate which is described in our blog check it out.

HTTPS is a protocol for secure communication over a computer network which is widely used on the Internet. More and more website owners are migrating from HTTP to HTTPS, mainly due to the 5 following reasons:

  1. Google announced that sites using HTTPS will get a slight ranking factor in Google search.
  2. You can achieve faster performance with the new HTTP/2 protocol which requires HTTPS due to browser support. And yes, Kinsta supports HTTP/2 on all servers.
  3. HTTPS is more secure and your visitor’s data is entirely encrypted.
  4. HTTPS can build trust by enabling the green padlock in the visitor’s web browser address bar.
  5. If someone is visiting a website from HTTPS and going to an HTTP website, the referral data is lost in Google Analytics. It usually ends up lumped together with the “direct traffic.” If someone goes from an HTTPS website to another HTTPS website, the referral data is still passed. So by migrating from HTTP to HTTPS, you can actually have more accurate referral data.


HTTP: In the early days, a protocol was designed which was hypertext transfer protocol aka HTTP to communicate from browser to web server. But eventually, a lot of hacker and attacker came across which was alarming and threatening for users cause whenever data transfer through HTTP protocol, it travels in simple clear text format.  So it was highly required to encrypt data while communicating both ways web server and a web browser through a secured protocol as sensitive data like credit card information, logging information, and a whole bunch of data that needs to be encrypted. Here comes the secured protocol HTTPS aka Hypertext Transfer Protocol Secure.  The main reason to launch this protocol was to encrypt data and ensure security while transferring data from the web server to the web browser.

Automatically Redirect Your WordPress Website’s Traffic from HTTP to HTTPS in WordPress Admin Area:

After your SSL certificate is installed on your hosting account, there are some modifications you’ll need to make as follows:

  1. Add HTTPS to the

Open wp-config.php in your WordPress root folder and add the following line somewhere before where it says That’s all, stop editing!. to your .htaccess file. Adding a few lines to your .htaccess file will automatically redirect your visitors to the HTTPS version of your website.

define(‘FORCE_SSL_ADMIN’, true);

Once you have updated the file, it’s time to test if it works. For that, try to access your login page with HTTPS in the URL, for example via If everything worked correctly, you should have a secure connection now. Then continue.

  1. Update the Site Address:

After moving the WordPress backend over to HTTPS, it’s time to do the same for the remainder of your site. You can do that by updating your site address under Settings > General.

Automatically Redirect Your WordPress Website’s Traffic from HTTP to HTTPS in cPanel:

  1. Go to your cPanel account and click to file manager.
  2. Once the file manager loads, click Settings.
  3. Make sure that Show Hidden Files (dotfiles) is checked, and click Save.
  4. Once you select the specific domain to be redirected (shown in the picture that is Document root), close the window and again click file manager from your cPanel.Click on public_html, and open your .htaccess if you already have one. If not, click File+, name the file .htaccess and click Create New File.
  5. Select the .htaccess file, and click Edit.
  6. If you just created your .htaccess file, use the following code to set up the URL redirect to the HTTPS version of your website:

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

Automatically Redirect Your WordPress Website’s Traffic from HTTP to HTTPS in Apache

  1. Login to your Apache server and go to the path where it’s installed.
  2. Go to the conf folder and take a backup of httpd.conf file
  3. Open httpd.conf using your favorite editor
  4. Ensure module is loaded 
  5. If you see  LoadModule rewrite_module modules/ this line is commented then uncomment it
  6. Add the following at the end of the file

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

7. Restart Apache web server to test it.

Automatically Redirect Your WordPress Website’s Traffic from HTTP to HTTPS in Nginx

  1. Login to Nginx web server and take a backup of nginx.conf or default.conf file (whatever file you are using for server directive)
  2. Add the following in server directive

    server {
    listen 80;
    return 301$request_uri;

  3. Save the file and restart Nginx web server
  4. Restart Nginx to test the site.

Automatically Redirect Website’s Traffic from HTTP to HTTPS in CloudFlare

If you are leveraging CloudFlare for performance and security then having a website through HTTPS is very easy. Cloud Flare provides free SSL cert, and you can do a redirection through page rules. The steps are given below:

  1. Log in to Cloud Flare and select the site
  2. Go to Page Rules
  3. Click “Create Page Rule”
  4. Enter the URL (put the asterisk, so redirection happens for all the URI)
  5. Click “Add a Setting” and select “Always Use HTTPS” from the drop-down
  6. Click “Save and Deploy”

It will take a few seconds, and you are all set to have your website accessible through https.




Recommended Posts
Contact Us

We'd love to hear from you, we'll get back to you soon.

Start typing and press Enter to search