Before you run redirection code,  you need to have Secure Sockets Layer (SSL) or Secure Certificate on your website. You need to keep in mind that just installing SSL certificate on your website doesn’t let your visitors automatically redirected to secured (HTTPS) version of your website. You need to write some codes in your functions.php or .htaccess file to