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.


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://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy

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 '18 at 5:44
  • 1
    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. – Marius Bughiu Nov 24 '18 at 12:33
  • This answer did not work for me. – Philippe Delteil Mar 13 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 at 10:19

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.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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