“Too many redirects” ONLY when trying to access wp-admin page

I figured I would ask my own question seeing as the duplicate question(s) still haven’t been answered.

For some reason after my fresh install of WordPress 4.9.1 on my Ubuntu VPS, enabling my “flexible” SSL issued by Cloudflare, and finally switching my URLs in WordPress (from “https://foo.com” to “https://foo.com”) I can no longer access my admin panel.

Attempted Fix #1: Clearing browser(s) cookies, cache, and saved data, as well as any Cloudflare caches.

Attempted Fix #2:
Modifying wp-config.php with the code:

define('WP_HOME' , 'https://foo.com');
define('WP_SITEURL' , 'https://foo.com');

Attempted Fix #3: Disabling .htaccess file in /var/www/html/

None of the above has worked and unfortunately I still cannot access the admin panel. However, the default wordpress homepage loads just fine at the correct secure, “https” URL.

6

I found a solution that fixed my issue.

Sources:

A.) https://sharpten.com/blog/2018/01/17/wordpress-stuck-many-redirects-error-loop-using-ssl.html

B.) (Sublink within A) https://wordpress.org/support/article/administration-over-ssl/

Excerpt:
Adding the following lines of code at the end of my wp-config.php file resolved the redirect conflict.

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
   $_SERVER['HTTPS']='on';

Leave a Comment