I don’t remember why I needed this solution at all, most likely because of infinitive redirects after editing .htaccess file. Below is a redirect option via functions.php:
function force_https () {
if ( !is_ssl() ) {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
exit();
}
}
add_action ( 'template_redirect', 'force_https', 1 );
WEBinP Your guide to resolving CMS optimization, Web Development and SEO problems