I just setup URL rewrites in NextJS to translate my URLs for my multilingual website.
This is how my next.config.js file looks:
module.exports = {
i18n: {
locales: ["da", "de"],
defaultLocale: "da",
},
async rewrites() {
return [
{
source: "/de/ueber-uns",
destination: "/de/om",
locale: false,
},
];
}
}
So if you try to access domain.com/de/ueber-uns (which is a page that doesn't exist), the URL will show the content from the /de/om page.
The problem is, that if you try to access /de/om, that URL will not redirect to /de/ueber-uns.
So I suspect that it will look like duplicate pages to Google/SEO and cause problems.
How can I avoid that (if possible)? Setting a redirect in next.config.js doesn't help.