From 523afccb51f5e19f0da301e7f475e799d27d5303 Mon Sep 17 00:00:00 2001 From: slawkens Date: Wed, 3 Jun 2020 20:01:26 +0200 Subject: [PATCH] Avoid ERR_TOO_MANY_REDIRECTS on template change --- system/template.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/system/template.php b/system/template.php index 773bbe24..2b38045a 100644 --- a/system/template.php +++ b/system/template.php @@ -25,7 +25,13 @@ if($config['template_allow_change']) } setSession('template', $template_name); - header('Location:' . getSession('last_uri')); + + $newLocation = $lastUri = getSession('last_uri'); + if($lastUri === $_SERVER['REQUEST_URI']) { // avoid ERR_TOO_MANY_REDIRECTS error in browsers + $newLocation = SERVER_URL; + } + + header('Location:' . $newLocation); } } else {