13

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.

21

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';
| improve this answer | |
  • There's a plugin for that – kero May 8 '18 at 5:44
  • 2
    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 '19 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 '19 at 10:19
  • 1
    If you use cloudflare, set SSL/TLS encryption mode to Full. That's it! It will load like a charm. – Jakir Hossain Dec 23 '19 at 13:48
3

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

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

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

| improve this answer | |
1

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

if($_SERVER['PHP_SELF']=="/index.php")
{
define('WP_HOME','https://yourdomain.com');
define('WP_SITEURL','https://yourdomain.com');
}
else
{
define('WP_HOME','http://yourdomain.com');
define('WP_SITEURL','http://yourdomain.com');
}

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

| improve this answer | |
1

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

| improve this answer | |
  • 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! – Trane Francks Aug 21 '19 at 1:28
0

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.

| improve this answer | |
0

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

| improve this answer | |

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