Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Redirect loop

Started by Muut Archive 10 years ago · 11 replies · 751 views
10 years ago

I've set up several redirects on my site using the 'Advanced > Page redirect' option. All have worked absolutely fine up until now; they simply go from a top-level page to one of that page's children.

However, having just enabled this for one more page - the last ordered top-level page (if that makes any difference) - I am now getting redirect loops from every page in the site (excluding the admin interface) to the location that I have just asked to redirect to.

The redirect I've just set up that's doing this is from /contact to /contact/info - so every page is redirecting to /contact/info, including /contact/info itself. What's going on here?

10 years ago

Can you please provide your 'raw' markdown file (if a page) or site.yaml (if you added them there). So i can take a look at your syntax?

10 years ago

Everything is specified on the pages themselves as it stands. (and just to clarify - all frontmatter is surrounded by ---s)

08.contact/default.md

YAML
title: 'Contact us'
redirect: /contact/info

08.contact/01.info/default.md

TXT

title: 'Contact info'
---
10 years ago

Hmm.. I don't see anything obvious. Perhaps you could zip up your user folder and PM the location I can download it and test it out?

10 years ago

Ok, this works fine in Grav 1.0.10, but it appears to cause the looping in Grav 1.1.0-beta. I'll take a look at this today.

10 years ago

Ok I found the problem. I think this is the same in Grav 1.0 as it is in 1.1, so you can probably just apply this same fix in your local:

https://github.com/getgrav/grav/commit/0b81fda01c6ad0beeb59244f324432ce90fd2551

Basically you have a page.find('/contact') in your footer links, this is called with redirect=false so it doesn't follow redirect links, however, this was falling into this check even when the page was legitimately found, skipping the check for page valid page. I broke out the page level redirect from this check and that sorted it.

Nasty little bug that really only happened because you were doing a find() on the same page you had a redirect in. All sorted now I think!

10 years ago

Actually hold on.. might of found an issue with my 'fix'

10 years ago

Excellent! Thanks. Will this fix be in the 1.1 release?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1365 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1124 9 years ago