ERR_TOO_MANY_REDIRECTS error - only some users !

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
david0058
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed Jan 20, 2016 10:58 pm

ERR_TOO_MANY_REDIRECTS error - only some users !

Post by david0058 » Sun Apr 22, 2018 2:13 pm

I have a problem on our live Joomla! 3.8.7 site where a few users are getting "... redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS" errors when trying to access any page on the site.

It seems to be restricted to a small number of people, who oddly get the problem on all devices they try (this has to be a weird coincidence, right ? Unless they're using their devices through a common router or something).

The sequence seems to be that they request a page, which for some reason can't be retrieved so they get redirected to my custom error 404 page, which can't be retrieved, which redirects them to my custom 404 error page, which can't be retrieved ... you get the picture.

I suspect that there's *something* on all pages that isn't accessible for some reason but I can't for the life of me find it ... or why the problem should affect some people but not others.

edit: I've eliminated the web server from the equation - the configuration hasn't changed for a couple of years anyway - but to confirm it I replaced the Joomla! index.php with a simple <?php phpinfo(); ?> script, which works for everyone. Swap the Joomla! one back in and the problem re-appears, so it's not a .htaccess or web server config issue.

Any ideas would be so gratefully received :)

Thanks !

David

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 28317
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: ERR_TOO_MANY_REDIRECTS error - only some users !

Post by Per Yngve Berg » Sun Apr 22, 2018 4:29 pm

Does it only occur when they login to the site?

Try to disable the Authentication Cookie Plugin.

david0058
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed Jan 20, 2016 10:58 pm

Re: ERR_TOO_MANY_REDIRECTS error - only some users !

Post by david0058 » Sun Apr 22, 2018 4:48 pm

Hi Per,

No, they don't get a chance to log in - can't even get to the home page.

Some more clarification:

1. if they enter a non-https page e.g. "http://xxx.org.uk/anypage" they correctly get a 301 Permanent redirect to "https://xxx.org.uk/anypage"
2. their browser then requests "https://xxx.org.uk/anypage" but then instead of getting that page, it gets a 302 Temporary redirect to "https://xxx.org.uk/404-page-not-found"

If they request the https page to start with they just get the 302 Temporary redirect straight away. This is the case for any page on the site.

I have no idea where this 302 is being generated ... or why it should go to my custom 404 page.

And it happens on some devices but not others, on the same version of the same browser. Works on some Chrome, not others, some Edge but not others, some Safari not others ... nightmare.

I've individually disabled each plugin that's installed on the system and tested to see if any of them make a difference - nothing. Same problem every time.

Cheers,

David

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 28317
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: ERR_TOO_MANY_REDIRECTS error - only some users !

Post by Per Yngve Berg » Sun Apr 22, 2018 7:21 pm

How did you do the redirect in point 1?

Did you set force ssl in configuration.php?

What is your content of the .htaccess file.

david0058
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed Jan 20, 2016 10:58 pm

Re: ERR_TOO_MANY_REDIRECTS error - only some users !

Post by david0058 » Sun Apr 22, 2018 10:48 pm

Hi Per,

I've tried a number of ways. Basically I want all requests to http://www.xxx.org.uk (port 80) to be redirected to https (port 443).

First I tried using mod_rewrite with a rewrite rule in my apache conf file and a rewrite rule in the .htaccess file of my root directory. I also tried a Rewrite directive instead of the rewrite rule in my apache conf file but this had the same effect as described above, on device/browser combinations where this redirect loop occurs.

I do have force_ssl = "2" in the configuration.php, and my .htaccess currently looks like:

Code: Select all

##
# @version $Id: htaccess.txt 14401 2010-01-26 14:10:00Z louis $
# @package Joomla
# @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##


#####################################################
#  READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations.  It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file.  If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's.  If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla! Directory (just / for root)

RewriteBase /

########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section

<IfModule mod_php5.c>
php_value post_max_size 128M
php_value upload_max_filesize 128M
php_value max_execution_time 300
php_value max_input_time 300
</IfModule>
The behaviour is totally consistent - on certain browser/device combinations there is always a redirect loop, on others there never is. Clearing cookies etc. has no effect, and I have no caching of any kind enabled on the web or Joomla! server.

I'm mystified and extremely concerned ... I suspect this has been a problem for a long time but nobody reported it.

Thanks for your reply,

David

User avatar
Giraffex
Joomla! Intern
Joomla! Intern
Posts: 72
Joined: Fri Jan 21, 2011 3:51 pm
Location: Guben
Contact:

Re: ERR_TOO_MANY_REDIRECTS error - only some users !

Post by Giraffex » Mon Apr 23, 2018 3:22 am

I have something like this when I redirect website to with www. and https.
Do you have some redirect in php?

david0058
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed Jan 20, 2016 10:58 pm

Re: ERR_TOO_MANY_REDIRECTS error - only some users !

Post by david0058 » Mon Apr 23, 2018 7:09 am

Hi,

No, it's a normal Joomla! 3.8.7 site.

What should happen is:

1a. The browser requests http://xxx.org.uk/get-some-page
2a. The web server issues 301 Permanent redirect to https://xxx.org.uk/get-some-page using .htaccess rules
3a. The browser requests https://xxx.org.uk/get-some-page
4a. The web server calls Joomla! which maps the SEF get-some-page to the correct article and outputs the content, which the web server returns to the browser.

What I believe is happening when this problem occurs is:

1b. The browser requests http://xxx.org.uk/get-some-page
2b. The web server issues 301 Permanent redirect to https://xxx.org.uk/get-some-page using .htaccess rules
3b. The browser requests https://xxx.org.uk/get-some-page
4b. The web server calls Joomla! which ("for some reason to be identified") calls the code in templates/my-template/error.php to return a 302 Temporary redirect to https://xxx.org.uk/404-page-not-found
5b. The browser then requests https://xxx.org.uk/404-page-not-found
6b. goto step 4b

After twenty iterations between step 6b and step 4b the browser detects that it's in a redirect loop and displays the "ERR_TOO_MANY_REDIRECTS" error page.

I don't know why step 3 in each case seems to be handled by some browsers/devices but not others, this is the "for some reason to be identified" bit in 4b.

The "get-some-page" above represents any page on the site, doesn't matter if it's the home page or not (so "https://xxx.org.uk/" causes exactly the same outcome - either works perfectly on some device/browsers or never works on others). I've also tried turning off SEF URLs in the global config but that makes no difference.

david0058
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed Jan 20, 2016 10:58 pm

Re: ERR_TOO_MANY_REDIRECTS error - only some users !

Post by david0058 » Mon Apr 23, 2018 12:03 pm

More info ... looks like a template clash with my Joomla version, probably triggered by some browser configurations.

The problem is in a TemplateHelper class in the template I'm using, in which the render() method is iteratively called to render different bits of each page (head, widgets, content etc.). This method pulls in the relevant code using PHP include - e.g. "include($__layout)".

When a successful device/browser combination is used, 31 calls are made to this function (often include-ing code modules that have been previously pulled in) and the page is displayed correctly.

When an unsuccessful combination is used, the 23rd call fails (out of memory ?). This results in my custom 404 code being called (templates/yoo_nano3/error.php). This code issues a 302 redirect in order to display the "No such page ..." article, and when the server tries to render this page the same problem occurs. After 20 iterations the browser detects the redirect loop and displays the error message.

I've contacted the vendors to see if there's a later version of the template available but I'm not confident ...

david0058
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Wed Jan 20, 2016 10:58 pm

Re: ERR_TOO_MANY_REDIRECTS error - only some users !

Post by david0058 » Mon Apr 23, 2018 9:43 pm

Final update - all fixed.

We didn't find the absolute root cause, but with a bit of stellar support from the guys at Yoothemes the problem is fixed. They tracked it down to a now-unsupported module for asking visitors for cookie permissions, and while it's not clear what it was doing as it was loaded on every page during rendering, it was the culprit. When it was unpublished everything that had been problematic suddenly worked fine. I'll delete the module completely once I've tested that doing that won't cause any problems.

Yootheme support team rocks !


Locked

Return to “General Questions/New to Joomla! 3.x”