Fixing the "Too many redirects" error

The error message "ERR_TOO_MANY_REDIRECTS" is something we see quite often. Usually, this suddenly pops up after a migration, a newly installed plugin, or a change in PHP version. Don't worry, solving this is quite simple and consists of two steps; modifying the wp-config.php file and modifying the .htaccess file. We explain how below.

1. Modifying wp-config.php

First of all, open the wp-config.php of your website. You can find this in the file manager in DirectAdmin (in the public_html folder). Add the following to the second to last line:

 

if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {

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

}

 

Save the file and go back to the file manager.

 

2. Modifying .htaccess

Usually, modifying the wp-config.php file is sufficient, but if you still see the error message you will also need to modify the .htaccess file. You can find this file, just like the wp-config.php file, in the file manager (in public_html).

Open the .htaccess file and look for the following line:

RewriteCond %{HTTPS} !=on [NC]

If this line is not there, it is fine. If it is there, place the following directly below it:

RewriteCond %{HTTP:X-Forwarded-Proto} !https
SetEnvIf X-Forwarded-Proto "https" HTTPS=on

The message should no longer appear.

Can't quite figure it out? Don't hesitate to send our support team a message, and we will take a look with you.


Still have questions? Get in touch.