Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PROBLEM Redirect error on parent page: ERR_TOO_MANY_REDIRECTS
#1
Hi, 

I'm having an ERR_TOO_MANY_REDIRECTS issue.

I've set up a gallery page on a website. This gallery has several sub-galleries (let's say gallery1 and gallery2). My link structure in the main menu is:

gallery
  • gallery1
  • gallery2

Now "gallery" is not a page users can visit. I did create a page in the GS admin panel in order to show "gallery" as parent of "gallery1" and "gallery2" in the main navigation. But the page "gallery" is empty. I have a bit of JavaScript that prevents its href='#' to do anything.  "Gallery" really only serves as parent in the main menu.

To prevent users from manually visiting the page by typing www,domain,de/gallery, I set a redirect in .htaccess from "gallery" to "gallery1", like so:
RedirectMatch 301 ^/gallery/$ /gallery/gallery1/

In the URL I can see that this redirect points me to the right address.

However, I get the error ERR_TOO_MANY_REDIRECTS. The error persists if I remove the redirect rule from htaccess. 

How can I fix the redirects error? Is there a better way to put "gallery" as parent in the main menu?

Greetings,
Marty
Reply
#2
Hi Marty,

The error “too many redirects” means that the website keeps being redirected
between different addresses in a way that will never complete.
Usually the error too many redirects comes from your browser.

1)
check that the base_url within your site is not conflicting with a redirect in the .htaccess file.
These conflicting redirects will flip flop back and forth and never complete.

2)
clear your cache and cookies in your browser.

3)
check there is no conflict between redirecting from http to https back and forth

4)
The next step in troubleshooting these kinds of redirect loops is to use the Developer Tools
in Firefox or Chrome. These tools are commonly opened by pressing the F12 key. Make sure you
select the Network tab in either of these and then reload the page you are having an issue with.
After reloading the page, you should see the series of redirects listed out for you in the new
window. Looking at the redirects, you can see if they are redirecting between a few different
things or redirecting to the same thing. Either way, you can see the steps that lead up to
the error, instead of just the end user’s browser error.
Reply
#3
Hello and thanks for your thorough answer!


1) My base_url is https://domain,de/ 

2) I cleared cookies and cache, but the error persists. I always test my websites cross-browser, and it's the same in Firefox, Chrome, Edge and Opera.

3) HTTPS-enfore in my htaccess:

Code:
 <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    # (1)
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
 </IfModule>


Suppressing www.: 

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    # (1)
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
</IfModule>

4)
301-Redirects for the parents "gallery" and "art" pages:

Code:
RewriteRule ^/photo-gallery$ https://domain.de [L,R=301]
RewriteRule ^/art-gallery$ https://domain.de [L,R=301]


It redirects me to https://domain,de/photo-gallery?lang=en. The language of the site is set to English in GS. 

The redirect loop happens if the link for photo-gallery or art-gallery is set to "#" in GS. 
I'm setting this link in GS via a custom field of type "link". 

If I set this link to "/child-gallery" and enter e.g. https://domain,de/photo-gallery, it redirects to https://domain,de/photo-gallery/child-gallery. 
That's good because Google won't find a defective page. But it's not ideal because users could click the parent link.
Reply
#4
Hi Marty,

Did you try with FireFox go to Web Developer and then go to Web Console  and then select Network ? (F12 button)

Or with Chrome go to More tools and then Developer tools  and then select Network (F12 button)

Open the page where it shows the error too many redirects and check what the Network console shows.
Reply
#5
Quote:Now "gallery" is not a page users can visit. I did create a page in the GS admin panel in order to show "gallery" as parent of "gallery1" and "gallery2" in the main navigation. But the page "gallery" is empty. I have a bit of JavaScript that prevents its href='#' to do anything.  "Gallery" really only serves as parent in the main menu.

This is actually a very useful option to have. A hidden page can be used to store and manage
assets, icons, javascript, css and settings for site wide use on other pages in the website.

1) Think about icons and graphics that are used on certain pages in the website.
You can store those icons and graphics with the ckeditor in a hidden page.
Another example could be managing the pictures on a rotating banner in a certain page.

2) Think about managing paths to certain javascript and css scripts that are used on
certain pages in the website. Those pages could read those paths from the hidden page
and then load the necessary javascript or css.

Sure this can also be done with setting up special fields but the possibilities
would be endless if such paths could be called simply from text lines in the hidden page
written with the ckeditor.

What already is possible in GS is to grab data from a separate page (in this case a hidden page)

<?php getPageField('page-slug-name','field-name'); ?>

More info about this:
http://get-simple.info/wiki/config:caching-function (bottom of page)
Reply
#6
Quote:This is actually a very useful option to have. A hidden page can be used to store and manage
assets, icons, javascript, css and settings for site wide use on other pages in the website.

1) Think about icons and graphics that are used on certain pages in the website.
You can store those icons and graphics with the ckeditor in a hidden page.
Another example could be managing the pictures on a rotating banner in a certain page.

2) Think about managing paths to certain javascript and css scripts that are used on
certain pages in the website. Those pages could read those paths from the hidden page
and then load the necessary javascript or css.

To come back on this how to realize such a hidden page, I just discovered the ItemManager from Bigin.
See this thread about the ItemManager plugin:
http://get-simple.info/forums/showthread.php?tid=7293

With this ItemManager plugin it is very easy to create such a hidden page to manage other pages.

To keep the url of such a hidden page from being accessible by a browser this plugin can be handy:
https://github.com/lokothodida/gs-front-router
Reply




Users browsing this thread: 1 Guest(s)