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 Answers 6


I found a solution that fixed my issue.


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)
  • There's a plugin for that
    – kero
    May 8, 2018 at 5:44
  • 5
    In case someone else stumbles onto this - those two lines worked for me, but only if I placed them at the top of wp-config.php. Nov 24, 2018 at 12:33
  • This answer did not work for me. Mar 13, 2019 at 21:17
  • If above did't help, you may try to add following line above: define('FORCE_SSL_ADMIN', true); and/or: "SetEnvIf X-Forwarded-Proto https HTTPS on the top" (without quotes, on the top of the file before anything else) to your .htaccess
    – S1awek
    Apr 13, 2019 at 10:19
  • 6
    If you use cloudflare, set SSL/TLS encryption mode to Full. That's it! It will load like a charm. Dec 23, 2019 at 13:48

I used the above answer by Matt and added one else case as well:

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

It worked. I had also placed it at the beginning of the wp-config.php

  • 2
    worked. Also it needs to be added to TOP after <?php otherwise it would give permission access error while accessing wp-admin Jun 2, 2020 at 16:46
  • This worked for me while the solution without the else didn't.
    – Sophivorus
    Jul 26, 2021 at 14:16
  • Thanks you made my day :) thanksssssssssssssssss Oct 25, 2022 at 23:21
  • Thanks man, worked foe me !!!
    – Raihan
    Mar 29 at 8:41

Put this code in wp-config.php in the first line inside the PHP tag.


But don't forget to replace your site URL in the place of yourdomain.com


Somehow, our wp-admin folder permissions was set to 777, which means everyone can read, write or execute to this folder.

We logged onto the server, and found an error saying "wp-admin cannot be writable by group."

We changed our permissions so the folder was not writable by group or world (755), and the admin area was immediately accessible.

(This permissions change did happen seemingly randomly for us. Our website's team didn't even have access to the server at the time wp-admin just stopped working and we still don't know how this setting was changed. The site had been up for several years beforehand.)

  • I've had the same problem and found several folders with 775 perms: wp-admin, wp-content, wp-includes. Changing them to 755 and now in the process of running malware scans to ensure nothing nefarious is afoot. Thank you! Aug 21, 2019 at 1:28
  • This was our issue too, and was the result of a hack. Changing permissions to 755 worked.
    – Kalnode
    Dec 24, 2020 at 14:01

I had the 'Too many redirects' on wp-admin only after migrating to a new server.

The problem was incorrect permissions on the folder wp-admin plus the top-level files within it. Resetting the permissions fixed the issue.

Hope that is of help to anyone who needs it.


In my case it was Apache's DirectoryIndex issue. The wp-admin was being accessed by wp-admin/index.php but not with wp-admin and showing ERR_TOO_MANY_REDIRECTS.

It sounds like Apache's DirectoryIndex may be set "incorrectly". Try resetting this at the top of your .htaccess file:

DirectoryIndex index.php

See the full answer here. Can't access admin dashboard with wp-admin without /index.php after it

Not the answer you're looking for? Browse other questions tagged or ask your own question.