🥰Sử dụng next.config chuyển localhost:3000 sang http://localhost:3000/en cách hay nhất (ok)
/** @type {import('next').NextConfig} */
module.exports = {
async redirects() {
return [
{
source: '/',
destination: '/en', // hoặc '/vi' tùy ngôn ngữ mặc định
permanent: true, // permanent: false: Dùng redirect tạm thời (status code 307). Nếu bạn muốn redirect vĩnh viễn (301), đặt thành true.
},
];
},
};
✅ Cách làm với module.exports trong next.config.js
module.exports trong next.config.jsjsCopyEdit/** @type {import('next').NextConfig} */
module.exports = {
async redirects() {
return [
{
source: '/',
destination: '/en', // hoặc '/vi' tùy ngôn ngữ mặc định
permanent: false,
},
];
},
};👉 Giải thích:
🔄 Nếu bạn muốn chuyển hướng theo ngôn ngữ trình duyệt?
PreviousSEO GRAPHQL theo type page, post, product (ok)NextHãy triển khai sử dụng đã ngôn ngữ nextjs, wordpress sử dụng plugin polylang
Last updated