Internal Netlify redirects don't redirect (using Gatsby <Link>)

Hello!

I’m attempting to set up a redirect for my site such that when I press on a “pricing” button users in the UK will go to /pricing/GB (instead of the normal /pricing route).

This post was helpful, but does not seem to work for all cases.

When I go directly to the /pricing URL with a UK IP, I correctly get redirected to /pricing/gb. However, if from my home page / I press on a Gatsby , the redirect is ignored.

I’m using Gatsby’s createRedirect with the gatsby-plugin-netlify plugin. My redirect in gatsby-node.js looks like:

createRedirect({
          force: true,
          fromPath: '/pricing',
          toPath: `/pricing/gb`,
          Country: 'GB',
          redirectInBrowser: true,
          statusCode: 200,
        })

I thought redirectInBrowser was what I was looking for (" set redirectInBrowser to true and Gatsby will handle redirecting in the client as well"), but it doesn’t appear to work.

Any advice on how to proceed or debug?

I’m hoping to avoid building an entirely different site for GB (as is suggested by this post).

Thank you!

Hi @dominicwhyte,

Are you able to link to the site so the existing behaviour can be checked?

When running the build to get static output, have you looked at the _redirects file that is generated?

Since Netlify is consuming the _redirects file that’s generated (and not the Gatsby or gatsby-plugin-netlify specific configuration), a good first step would be checking what Netlify is actually being given.

1 Like