next.config.mjs 파일에 설정
/** @type {import('next').NextConfig} */
const nextConfig = {
async redirects(){
return[
{
source: 'products/temp',
destination: 'products',
permanent: true;
},
];
};
};
export default nextConfig;
source로 접속했을 때 변경된 route를 destination에 기재, 영구적으로 변경됐는지 permanent true로 확인
redirect 되면 308코드를 받게 됨
const nextConfig = {
async rewrites(){
return[
{
source: '/my',
destination: 'me/info',
},
{
source: '/items/:slug',
destination: 'products/:slug',
},
];
};
};
중요 정보를 포함한 route일 때 대체하거나 복잡한 구조를 간편한 url로 변경할 때 rewrite를 사용한다.