Pricing Blog

How to prevent redirect loop

  • fss21.-1364570463363137566

    fss21

    3 months ago

    Hi, i creatd API redirect rule. basically if the url does not end with slash, then I want to redirect the same url with slash at the end.
    The logic to judge whether slash is at the end is working fine.

    but when i implement this logic, the redirect loop happens in preview page. anyone knows why is this happening?
  • erikbeus-1364571107985985577

    Erik Beuschau

    3 months ago

    I believe the client changes the url itself. Currently, the Nordcraft router doesn't support trailing slashes. It's on our internal roadmap to figure out if this should be supported
  • fss21.-1364571459027996712

    fss21

    3 months ago

    thanks for quick response! so currently there is no way to achive this in toddle?
    1364571458738851891-image.png
  • erikbeus-1364571649747320909

    Erik Beuschau

    3 months ago

    No, I don't think so. Are the trailing slashes important to you?
  • fss21.-1364572000357711923

    fss21

    3 months ago

    yes it is.
    it seems that Google bot wrongly sees the url without slash at the end as canonical page in some cases
    our canonical url has slash at the end. So this is really bad for seo...
  • Tod-1364572002484092969

    Tod

    3 months ago

    Great job @fss21! Your contribution to the Nordcraft Community just made you advance to Community Level 1! 🌲
  • fss21.-1364572180171587594

    fss21

    3 months ago

    we have set canonical url in a correct way though
  • erikbeus-1364943856726048778

    Erik Beuschau

    3 months ago

    Does the canonical tag help you with Google's indexing?
  • fss21.-1364944984024944691

    fss21

    3 months ago

    yes it helps but we want to force redirect in case Google set wrrong url as canonical url
  • erikbeus-1364945818687373323

    Erik Beuschau

    3 months ago

    Got it. This is something we will need to discuss internally how we want to handle. Different frameworks handle this differently and we want to make sure we handle it in a way that is flexible. I'm sorry I don't have a great solution for you right now.
  • fss21.-1364950128649043968

    fss21

    3 months ago

    got it. thanks for sharing this and looking forwawrd to update!
  • fss21.-1380760686677856368

    fss21

    1 month ago

    Hi there, just wondering if there is any update on this?
    Page is accessble whether there is slash at the end or not and it seems that it is confusing google bot because they are indexing both pages even though I have set up canonical already.

    You guys published new features so wondering if there is any solution now
  • Tod-1380760688451911722

    Tod

    1 month ago

    Great job @fss21! Your contribution to the Nordcraft Community just made you advance to Community Level 3! 🌲
  • fss21.-1381917186993426482

    fss21

    1 month ago

    Hi @Erik Beuschau hope you are well. I guess there is no update for this yet?
  • erikbeus-1381917460818690130

    Erik Beuschau

    1 month ago

    Only update is that we plan to discuss this internally this week (not much of an update though). Let me get back to you with a status update on Friday 🙏
  • fss21.-1381917553445830778

    fss21

    1 month ago

    awesome! thank you so much for quick response
  • erikbeus-1383081677831802968

    Erik Beuschau

    1 month ago

    Our discussion was postponed to next week. I'll keep you updated
  • erikbeus-1384147072223154228

    Erik Beuschau

    1 month ago

    Alright. I have some positive and some negative news for you 😉

    The positive:
    - It's technically possible with our new redirect solution (still feature flagged at https://app.nordcraft.com/flags)
    - You might need to set up multiple redirects, and potentially detect whether a url is missing a trailing slash with a regex. Here's a simple implementation https://editor.nordcraft.com/projects/trailing_slash/branches/start/routes/Trailing%20slash?canvas-width=800&canvas-height=800&selection=routes.Trailing%2520slash.destination&rightpanel=style
    - You can see the redirect behavior here https://start-trailing_slash.toddle.site/yoyo (which should redirect with a 302 to https://start-trailing_slash.toddle.site/yoyo/)

    The negative:
    - While we do want to support a better way of configuring trailing slash behavior on a project, that is not the most urgent issue on our roadmap atm
    - Using the redirect behavior above, you might need to set up multiple redirects - and specifically the index page (on /) behaves a bit strange when you try to parse it (see screenshot)

    We plan to release redirects this week. The docs has not been updated yet, but we do have a PR ready for it here https://github.com/nordcraftengine/documentation/pull/295

    https://cdn.discordapp.com/attachments/1070246768983408710/1384139451453931543/CleanShot_2025-06-16_at_13.55.19.png?ex=685157d1&is=68500651&hm=87e8da0e8aad0e40bf5b800891cd9bd344799e9e429b4dfb9f3ddbe9fd17e466&
  • fss21.-1385559441641967688

    fss21

    1 month ago

    Thank you so much for this ! Will try this! This was quite a issue for us
    🙌1