Please, don\'t recommend me the long and very detailed thread with more than 173 upvotes. It didn\'t work for me. I have also tried many others (1, 2, 3, 4). They all give m
Here is an alternative solution you can use if you don't want to edit .htaccess:
add_action( 'template_redirect', 'nonhttps_template_redirect', 1 );
function nonhttps_template_redirect() {
if ( is_ssl() ) {
if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'https' ) ) {
wp_redirect( preg_replace( '|^http://|', 'https://', $_SERVER['REQUEST_URI'] ), 301 );
exit();
} else {
wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
exit();
}
}
}
You can place this at the bottom of your theme functions.php