WordPress and Flexible SSL in Cloud Flare

To use Flexible SSL in Cloudflare for WordPress, add the following code to the wp-config.php file. Add this code before `/* That’s all, stop editing! Happy blogging. */`.

$https_options = array( 'HTTP_CF_VISITOR', 'HTTP_X_FORWARDED_PROTO' );
foreach ( $https_options as $https_option ) {
	if ( isset( $_SERVER[ $https_option ] ) 
	    && ( strpos( $_SERVER[ $https_option ], 'https' ) !== false ) 
	) {
		$_SERVER[ 'HTTPS' ] = 'on';

View the code on Gist.

After adding this code and enabling Flexible SSL in Cloud Flare, you can change the website address to https://.

About grola

Passionate about Wordpress and WooCommerce for many years. Author of plugins and short snippets improving Wordpress and WooCommerce.

View all posts by grola →