How to Fix the WordPress Redirect Loop (Cloudflare SSL)

Using Cloudflare as the DNS of your WordPress blog can result in a redirect loop that will make the admin panel unreachable. In this article, we’ll discuss how to fix that issue.

Fixing Issues - How to fix WordPress redirect loop?
Fixing

First, make sure your site URL in WordPress is in the HTTPs version. You can change this in the admin panel. However, in this case, we aren’t able to access it. So, you can carefully change the wp-options table through PHPMyAdmin.

Go to that table. Find the row where the option_name is equal to siteurl. Change the optional_value to HTTPS version of your website. (Ex: http://talk.hyvor.com to https://talk.hyvor.com) – It doesn’t matter if you have installed WordPress on a directory or not.

Finally, add the following code to wp-config.php.

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

Everything should be fine now. If not, please comment below.

Why does it Fix the WordPress Redirect Loop?

Here’s the reason if you wish to know. When you set up Cloudflare for SSL, Cloudflare will use a flexible SSL where the connection with the user is made via HTTPS and the connection with your server is made via HTTP.

After changing the WordPress URL to HTTPS, it will try to automatically redirect the HTTP traffic to HTTPS. As the connection between your server and Cloudflare is an HTTP one, it will cause a redirect loop.

By adding the above code to the wp-config.php file, you tell WordPress explicitly to handle this request as an HTTPS one. Therefore, it will fix the WordPress redirect loop issue when using Cloudflare SSL.

Need a privacy-focused commenting platform for your website?