Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
Next.js i18n translate URL occurs 404 error?

I'm making a multilingual service using next-i18next. I wanted some of my routes translate too for instance:

EN: /contact => default language

IT: /fa/ارتباط-با-ما => second language

For this purpose, I used translated URL routes by rewrites in my next.config.js file.

/** @type {import('next').NextConfig} */

const { i18n } = require('./next-i18next.config');
const nextConfig = {
  i18n,
  async rewrites() {
    return [
      {
        source: '/ارتباط-با-ما',
        destination: '/contact-us',
      },
    ];
  },
};

module.exports = nextConfig;

I created my navigation with this guide:‌ How to setup i18n translated URL routes in Next.js?

you can check out my code there https://stackblitz.com/edit/nextjs-thwgak

Problem:‌ Go to the home page then change the language to Farsi after that go to the contact page you see so far so good but when you reload the page on the contact page you get a 404 error.

Is this a bug or am I wrong? Where did I go wrong? Any idea?

ps question: what do rewrites affect SEO?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The word ارتباط-با-ما gets URL encoded when it reaches the Next.js server, so you have to also encode your source value accordingly for it to match the rewrite rule.

const nextConfig = {
    async rewrites() {
        return [
            {
                source: `/fa/${encodeURIComponent('ارتباط-با-ما')}`,
                destination: '/fa/contact-us',
                locale: false
            }
        ];
    }
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!