Force the URL to redirect to HTTPS, Force ssl (ok)

https://help.dreamhost.com/hc/en-us/articles/218428687-How-do-I-use-an-SSL-certificate-with-WordPress-

Step 4 — Update your wp-config.php file

  1. Log into your webserver via SSH or SFTP.

  2. Find the file named wp-config.php in your WordPress site directory, and then open it in a text editor.

  3. ​Add the following two lines above the line that​ says /* That's all, stop editing! Happy blogging. */:

    
    define('FORCE_SSL_ADMIN',true); 
    define('FORCE_SSL_LOGIN',true); 
    Khong có: define('FORCE_SSL', true);

Force the URL to redirect to HTTPS, Force ssl

add_action('template_redirect', 'webroom_force_ssl');
function webroom_force_ssl(){
	if (!is_ssl()) {
		wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301);
		exit();
	}
}

Last updated