Author Topic: ERR_TOO_MANY_REDIRECTS  (Read 12299 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
ERR_TOO_MANY_REDIRECTS
« on: January 20, 2020, 05:22:32 AM »
Hello, good evening everyone, I have a problem I hope you can help me.

I can't see my page, I get this error:

ERR_TOO_MANY_REDIRECTS

the funny thing is that eliminating the .htaccess is solved, but if I go to some menu it fails again and automatically the .htaccess reappears.

This is the .htaccess code

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^.*[-](\d+)/(.*)/$ installo/index\.php?id=$1&%{QUERY_STRING} [L]
RewriteRule ^.*l/(.*)/$ installo/index\.php?cat=$1&%{QUERY_STRING} [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

I am using Nginx & Varnish & Apache

Offline
*****
Re: ERR_TOO_MANY_REDIRECTS
« Reply #1 on: January 21, 2020, 07:48:58 AM »
Try to use the https redirect first
You can ask me to solve any problem with your server for some money in pm  ;)
Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor
Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp

Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
*
Re: ERR_TOO_MANY_REDIRECTS
« Reply #2 on: February 24, 2020, 03:51:29 PM »
I have been trying to trace down the same problem. I managed to identify the exact problem, and I am putting it here for requesting a solution.
The ERR_TOO_MANY_REDIRECTS appears for the wordpress homepage only and it goes away and then comes back on my site, Thinkbalm. This periodical bahavior gave the clue that it is a cache-related problem.


Status 301 Moved Permanently
Server nginx/1.16.1
Date Mon, 24 Feb 2020 15:46:29 GMT
Content-Type text/html; charset=iso-8859-1
Content-Length 230
Connection keep-alive
Keep-Alive timeout=60
Location https://thinkbalm.com/
X-Varnish 98379 131369
Age 13
Via 1.1 varnish (Varnish/5.2)
X-Cache HIT from Backend


I am using Nginx > Varnish > Apache, php-fpm. Setting the domain's configuration to Nginx > Apache, thereby taking out Varnish solves the problem, but then you lose your Varnish cache.  Therefore I did a lot of searching and the problem seems to be the following:

Varnish and SSL - WordPress Behind an HTTPS Terminating Proxy


Varnish is a reverse caching proxy server that speeds up the performance of your website. It is commonly used in conjunction with WordPress.

Unfortunately, Varnish does not support SSL. So we need to terminate the SSL connection and speak plain HTTP with Varnish and your WordPress site.

Not only does Varnish not support SSL, it is also unaware of the SSL termination and just uses the hostname and the URL of the request as an identifier.

We trigger a problem: forcing HTTPS redirects on an application that is not aware what the initial request protocol, can cause ERR_TOO_MANY_REDIRECTS errors in your browser.

This happens when the HTTP version of a page is stored in cache. The output is nothing more than a 301 redirect to the HTTPS version. But because Varnish and WordPress are unaware of SSL termination, you’ll end up in a redirection loop until the browser throws this error.

How can we solve this?

I tried adding this to the wp-config file:

if($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){
   $_SERVER['HTTPS'] = 'on';
   $_SERVER['SERVER_PORT'] = 443;
 }

I also tried to add this to .htaccess:

SetEnvIf X-Forwarded-Proto "https" HTTPS=on
Header append Vary: X-Forwarded-Proto

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

None of these resolved the situation.

Any ideas?
Peter Nyiri
FunnelXpert

Offline
*****
Re: ERR_TOO_MANY_REDIRECTS
« Reply #3 on: February 24, 2020, 07:31:48 PM »
clear the varnish cache and restart varnish for the checks.

Offline
*
Re: ERR_TOO_MANY_REDIRECTS
« Reply #4 on: February 24, 2020, 11:08:30 PM »
clear the varnish cache and restart varnish for the checks.

Yes, I did that, but it's only a temporary fix.
The problem comes back and I cannot be there each time to manually restart.

Excluding the home page could be a solution, but how do I do that?
Peter Nyiri
FunnelXpert

Offline
*****
Re: ERR_TOO_MANY_REDIRECTS
« Reply #5 on: February 25, 2020, 09:22:30 AM »
better to check your site compatibility with varnish and there are no internal redirect by script. all redirects should be server side.

Offline
*
Re: ERR_TOO_MANY_REDIRECTS
« Reply #6 on: March 01, 2020, 08:24:43 AM »
The setup is regular WordPress. Nothing special.

I found a handling that works for me:

https://saadhost.com/solved-err_too_many_redirects-varnishnginx/
Peter Nyiri
FunnelXpert