How to fix WordPress redirect loop error after enabling SSL on Cloudflare

Reading Time: < 1 minutes

When activating Cloudflare SSL on the new WordPress installation on the new domain, it’s quite common that website stuck on redirect loop. That’s annoying, but easy to fix by adding just one line of code on WP configuration file.

Open the wp-config.php file located at the public root using your favorite FTP-client or control panel file editor and find the following line:

/*That’s all, stop editing! Happy blogging. */

Insert the following code just before the above line and save.

$_SERVER['HTTPS'] = 'on';

You can also add the following lines to make sure WP uses only SSL

define('FORCE_SSL_ADMIN', true);
define( 'WP_HOME', '' );
define( 'WP_SITEURL', '' );

Reload the URL and now WP redirect loop should be fixed!

5/5 - (1 vote)
See also  How to disable WordPress PHP errors

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.