What's the difference between Redirect and Rewrite?

Younggeun called as Jay·2024년 4월 8일

Rewrites vs Redirect

Rewrites is a rewrite, on the other hand, modifies how the server delivers content without the user's browser ever knowing.
Redirects is a redirect instructs the user's web browser to completely switch to a different URL.

Next.js

To use rewrites use the rewrites key in next.config.js:

module.exports = {
  async rewrites() {
    return [
      {
        source: '/about',
        destination: '/',
      },
    ]
  },
}

To use redirects you can use the redirects key in next.config.js:

module.exports = {
  async redirects() {
    return [
      {
        source: '/about',
        destination: '/',
        permanent: true,
      },
    ]
  },
}
profile
까먹을때마다 보려고 올리는 나의 기록

0개의 댓글