title: Next.js rewrites - access original request parameters
body: <p>I am building a navigation system for a Next.js app that would have routes like</p>
  <ul>
  <li>http://localhost:3000/docs/section1/pageName</li>
  <li>http://localhost:3000/docs/section2/pageName</li>
  <li>etc</li>
  </ul>
  <p>Under the hood these routes will point to a page <code>/docs/:slug</code> which is achievable with rewrites:</p>
  <pre><code>  async rewrites() {
      return [
        {
          source: '/docs/section1/:slug',
          destination: '/docs/:slug'
        },
        {
          source: '/docs/section2/:slug',
          destination: '/docs/:slug'
        }
      ];
    }
  </code></pre>
  <p>But I'd like to pass the <code>sectionN</code> as a context variable to the destination path. So that the <code>slug</code> page could know which section was referred to originally. The purpose is to minimize the amount of underlying pages but to keep the pages navigation meaningful to user or search bot.</p>
  <p>I understand that rewrites support/api can be limited. Checking the <code>context</code> in <code>getInitialProps</code> - original artificats are not available.  Is there a way maybe to approach this differently in Next.js?</p>