Fix: CloudFlare Redirect Loop and Other SSL Issues

Fix: CloudFlare Redirect Loop and Other SSL Issues

There is an easy solution for the SSL issues you’re having after enabling CloudFlare SSL.

CloudFlare Endless Redirect Loop Error

After enabling CloudFlare SSL on your site, You might get some issues like,

  • Site not secure or Invalid SSL Warnings
  • Your WordPress site going into Endless Redirect Loop
  • ERR_TOO_MANY_REDIRECTS
  • WordPress wp-admin going into Redirect Loop

Or any similar issue or errors. They are all caused by enabling CloudFlare SSL.

You must have tried to find a solution using Google, but most of the websites and forums are providing solutions that simply don’t work. I was in the same situation as you are, Stumbling through countless sites and forum trying to find a fix so my website can open.

I also contacted my hosting provider but they asked me to wait 24 hours. But I knew there was some issue, And even after 24 hours, the issue was there.

In some cases, the solution is simply to change SSL status from Full to Flexible on CloudFlare. But that doesn’t solve the issue for most.

But for some reason, anyone you ask for help will ask you to make sure that it’s set to Flexible, Even though it’s already set to Flexible. That makes you frustrated on finding the cause behind this.

But do not worry, we have an easy fix for the WordPress redirect loop on CloudFlare SSL or any other CloudFlare SSL related issue you’re getting.

Now without wasting any more of your time,

Here is the fix that will resolve the CloudFlare SSL issue you’re having:

First, Edit wp-config.php file from your WordPress root through Cpanel or FTP (whichever is your preferred method for editing files).

Now in wp-config.php, Locate this line:

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

Now before this line, Add following line:

$_SERVER[‘HTTPS’] = ‘on’;

And save the wp-config.php file.

For example, This is what my wp-config.php file looks like:

wp-config.php CloudFlare Redirect Fix

Now go ahead and try to load your site again. In most cases, it should load normally without any issues. But if you still have any issues, you can comment below and we’ll try to help you further.

  • David Savage says:

    Thanks Vinod!

  • Guest says:

    It worked thanks man! You are great

  • Michelle says:

    I was so hopeful your solution would work for me but unfortunately it didn’t. My website is stuck in the redirects loop and Cloudflare aren’t being much help. I have Flexible SSL with ‘always use https’ on, as advised elsewhere I contacted my origin host (Bluehost) to remove the http redirection from their end. And I’m still stuck! Any advice would be much appreciated! 🙂

    • I have found that using Flexible SSL on CloudFlare with Bluehost causes this issue as well. So you could try using Full SSL instead and that will most probably resolve the issue.

  • ian says:

    Thanks for this, this fixed my issue instantly.