복잡한 URL, 보안상 민감한 URL에 속한 키 등등 기존 URL을 지정하 URL로 대체시킴.
참고 : 기존 URL로 접근이 불가능한 것은 아님.
사용방법
•
next.config.js 파일에서 관리
•
rewrites()함수는 배열 형태로 리라이트 규칙을 반환.
프로퍼티
•
source:  대체할 URL 경로를 나타냄.
•
destination: 원래의 URL 경로를 나타냄.
// 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,
      },
    ];
  },
  async rewrites() {
    return [
      {
        source: "/kjh",
        destination: "/about/me/kjh",
      },
      {
        source: "/items/:slug",
        destination: "/products/:slug",
      },
    ];
  },
};
module.exports = nextConfig;
TypeScript
복사
