【发布时间】:2022-01-03 23:08:10
【问题描述】:
当我以这种方式重定向时:
{
source: "/restauracja",
destination: "/restaurant",
permanent: true,
},
它将我重定向到 /pl/restaurant
如何在没有第二个“pl”的情况下修复它并重定向?它仅在重定向时发生,通常默认本地不会在 url 中显示自己。这对 SEO 来说是个问题,因为它会复制网站。我想做从 domain.pl/pl/* 到 domain.pl/* 的 301 重定向的全局设置,但不知道该怎么做,我无法通过搜索找到解决方案。
在 next.config.js 中的样子:
...
i18n: {
// These are all the locales you want to support in
// your application
locales: ["pl", "en", "de"],
localeDetection: false,
// This is the default locale you want to be used when visiting
// a non-locale prefixed path e.g. `/hello`
defaultLocale: "pl",
// This is a list of locale domains and the default locale they
// should handle (these are only required when setting up domain routing)
},
async redirects() {
return [
{
source: "/restauracja",
destination: "/restaurant",
permanent: true,
},
{
source: "/klub-pub",
destination: "/club",
permanent: true,
},
{
source: "/kawiarnia",
destination: "/cafe",
permanent: true,
}
];
},
});
感谢您的帮助
【问题讨论】:
标签: javascript reactjs redirect next.js i18next