It works! Thank you Sir Paul. And for those running forced …

By 22nd March 2019 Uncategorised

Comment on WordPress CloudFlare Flexible SSL – Making It Work by Mark Llego.

It works! Thank you Sir Paul.

And for those running forced SSL on admin and you don’t want links to the front end to remain https here’s the code I’m using.

	add_action( 'template_redirect', 'bhww_ssl_template_redirect', 1 );
 
	function bhww_ssl_template_redirect() {
 
		if ( is_ssl() && !is_admin() ) {
		
			if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
			
				wp_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ), 301 );
				exit();
				
			} else {
			
				wp_redirect( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
				exit();
				
			}
			
		}
		
	}