200 URL rewrite and Gatsby

Hi,

I’m trying to use URL rewrites with gatsby but it doesn’t work as expected. The URL is https://keen-hamilton-1f404d.netlify.app/fr_CA/abc. You’ll see that it’ll be redirected to another URL whereas the expected behavior is to keep the same URL.

Also, when I use netlify dev, it shows redirect to /region1/fr/abc but doesn’t actually redirect. I was able to see Rewrote URL to /region1/fr/abc in the console, though.

Below is my _redirects file:

/fr_CA/*    /region1/fr/:splat  200!

Thanks for the help!

Hey @linton

I believe this is everything to do with Gatsby itself. In the page source you’ll see

<script id="gatsby-script-loader">
/*
<![
  CDATA[ */
    window.pagePath="/region1/fr/abc/";
    window.___webpackCompilationHash="2899d283c7271686bd39";
  /* ]
]>
*/
</script>

which is the path for the current page. This is covered in this documentation.

Exactly how to change this (or if it is actually possible) I cannot say. Reaching out to the Gatsby community might help.

2 Likes