Redirect to SPA locale build with splat

My app is an Angular SPA and a different build is created for each locale, for example:


And so on.

I have been trying, and failing, to set up a conditional redirect that includes a splat and works with a SPA.

For example, I’d like to redirect /register to /en-gb/register for users arriving from the UK. However, while the redirect part works, it doesn’t seem to then do the proxying bit that makes the SPA work. Instead I get the Netlify 404 page.

This is the config I’ve got at the moment:

  from = "/*"
  to = "/en-gb/:splat"
  status = 302
  conditions = {Country = ["gb"]}
  force = true

  from = "/en-gb/*"
  to = "/en-gb/index.html"
  status = 200

I’ve tried with and without force and with a 200 status too.

I guess it is processing the redirect but then not the subsequent rewrite.

Any ideas how I would achieve what I want to do?

My site is but I’m experimenting on the staging branch deploy.

It’s because Netlify stops applying any redirect rule after the first match. So, when you match with /* it’s matching /en-gb/* too, but since the 302 redirect is listed before, it takes preference. You should consider switching the 200 rule above the 302 rule.

And… it’s so obvious when you point it out! THANK YOU, it works (of course)!

1 Like