title: Nextjs, catchall, static generation and redirects
body: <p>I have a website using nextjs 10.1</p>
  <p>I am using SSG and a catchall strategy, i.e. under /pages, I have</p>
  <pre><code>-pages
  --[...slug]
  ---index.tsx
  </code></pre>
  <p>and in my index.tsx I have</p>
  <pre><code>export const getStaticProps: GetStaticProps = async (context: any) =&gt; {
  const { params, locale } = context;
  const slug = params.slug;
  //multiple slugs can lead to the same page
  ...
  }
  
  export const getStaticPaths: GetStaticPaths = async () =&gt; {
  ...
  return {
      paths,
      // Fallback blocking ensures that pages not listed in getStaticPath will still be rendered with a call to getStaticProps
      fallback: 'blocking',
    };
  }
  </code></pre>
  <p>In my headless cms (primic), slug history is saved (which is quite useful) and then multiple slugs an lead to the same page beacause I also parametered fall
  As of today, the right canonical tag is rendered for those multiple versions, with a link to the last slug parametered on prismic.</p>
  <p>I would prefer a 301.</p>
  <p>How can I create a 301 from my getStaticProps or how can I structure my /pages/[catchall] so that I have 301 from old slugs to new ones?</p>
  <p>Thanks a lot for the help!</p>