Can't get redirects to work on a Hydrogen site

I have a Hydrogen site built on marielichtenberg.netlify.app with the custom domain marielichtenberg.com

I have tried creating a _redirects file in my publish directory with the following content:

/products/baby-locket-coco-diamants-ml-00064 /fr-fr/products/coco-diamonds-baby-locket 301!
...

And also (on a separate deploy, after deleting the _redirects file) I tried creating a netlify.toml file with the following content:

[[redirects]]
  from = "/products/baby-locket-coco-diamants-ml-00064"
  to = "/fr-fr/products/coco-diamonds-baby-locket"
  status = 301
  force = true

...

On both occassions, this is was my deploy summary…

But when visiting the URL https://marielichtenberg.com/products/baby-locket-coco-diamants-ml-00064 I just get my 404 page, which is basically my site resolving the URL (i.e. shadowing). And if I look in my edge function log I can see this is the case…

Jan 19, 08:47:16 PM: info   [handler] GET streaming SSR     200 ok    1860.00 ms https://marielichtenberg.com/products/baby-locket-coco-diamants-ml-00064

How can I get redirects to work?

Hi @sel :wave:t6: welcome to the forums. I just checked out your site and it’s loading fine for me?

If you are still experiencing this issue can you check out this support guide?

Hi @SamO, thanks for your message. I have undertaken all of the advice on that link.

I’m not sure if you saw the link at the bottom of my post, this one: https://marielichtenberg.com/products/baby-locket-coco-diamants-ml-00064

So if you read my example redirect files you should see that clicking that link should redirect. However, it does not…

Hydrogen relies on Netlify Edge Functions, you should try to configure redirects from within Hydrogen. I am not aware of any way myself (that’s also because I haven’t used Hydrogen much), but if there’s no way to redirect, you might want to serve a HTML file with Meta refresh - Wikipedia

1 Like