특정한 사용자가, 어떤페이지에 들어올 경우 특정 조건에 의해 다른 페이지로 Redirect 시킬 수 있다.
사용방법
•
next.config.js 파일에서 관리
•
redirects()함수는 배열 형태로 리디렉션 규칙을 반환.
프로퍼티
•
source: 원래의 URL 경로를 나타냄.
•
destination: 리디렉션 후 이동할 URL 경로를 나타냄.
•
permanent: 리디렉션의 유형을 나타내며, true이면 영구 리디렉션(301 Redirect)을 의미하고, false이면 일시적인 리디렉션(302 Redirect)을 의미.
// next.config.js
const nextConfig = {
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "nextjs.org",
      },
    ],
  },
  async redirects() {
    return [
      {
        source: "/products/deleted_forever",
        destination: "/products",
        permanent: true,
      },
      {
        source: "/products/deleted_temp",
        destination: "/products",
        permanent: false,
      },
    ];
  },
};
module.exports = nextConfig;
TypeScript
복사
