Redirects on Language not working

Dear Community

I am building a multi-lang site with Next.js SSG. Sadly I was not able to configure it properly, so that people are redirected to its default browser language.

The redirection rules should be like:

  • Language = es ? → redirect to /es
  • Language = it ? → redirect to /it
  • any other Language → no redirect / fallback to /de

Some context:

Netlify TOML so far:

[[redirects]]
  from="/"
  to="/es"
  status=302
  force=true
  conditions = {Language = ["es"]}


[[plugins]]
  package = "netlify-plugin-next-dynamic"

Build output

5:43:31 PM: Page                                                           Size     First Load JS
5:43:31 PM: ┌   /_app                                                      0 B            59.2 kB
5:43:31 PM: ├ ● /[[...lang]]                                               4.68 kB        63.9 kB
5:43:31 PM: ├   └ css/022ecc98e5ade09e0f40.css                             509 B
5:43:31 PM: ├   ├ /
5:43:31 PM: ├   ├ /de
5:43:31 PM: ├   ├ /es
5:43:31 PM: ├   └ /it
5:43:31 PM: └ ○ /404                                                       3.46 kB        62.7 kB
5:43:31 PM: + First Load JS shared by all                                  59.2 kB
5:43:31 PM:   ├ chunks/f6078781a05fe1bcb0902d23dbbb2662c8d200b3.1027d5.js  10 kB
5:43:31 PM:   ├ chunks/framework.085e84.js                                 40 kB
5:43:31 PM:   ├ chunks/main.de325e.js                                      8.23 kB
5:43:31 PM:   ├ chunks/pages/_app.82b5d9.js                                278 B
5:43:31 PM:   ├ chunks/webpack.ccf5ab.js                                   751 B
5:43:31 PM:   └ css/784604cf6d43a63f5c68.css                               404 B
5:43:31 PM: λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
5:43:31 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
5:43:31 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
5:43:31 PM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
5:43:31 PM: Redirects
5:43:31 PM: ┌ source: /:path+/
5:43:31 PM: ├ destination: /:path+
5:43:31 PM: └ permanent: true

Many thanks for any kind of help! :slight_smile:

Hey there! If your browsers have language quality, this may be the issue.

The rule looks fine and should work as expected. However, I can’t be sure on this given the page is password protected and the tools I’m using to diag.

Hey @Scott

Thank you for the answer. I did testwise just set nf_lang=es like document.cookie = "nf_lang=es". Then

  • I tried to reload --> I am still getting the german site
  • I tried to re-open the browser and call the site --> Still getting the german site

Did I do something wrong?

Thanks!

Nevermind, after redeploying the site, it seems to work :slight_smile:

Thank you very much for your advice!