Can I redirect from a subdomain to a subpath?

Vercel (and Next.js) both offer the ability to add Redirects and Rewrites to your application. This approach is for commonly used for subpaths. For example, adding a redirect from acme.com/old to acme.com/new.

If you want to redirect app.acme.com to acme.com/app, you'll need to configure a proxy deployment.

Configuring a Proxy Deployment

  1. First, create a new project inside Vercel.
  2. Next, add the subdomain to your project settings (e.g. app.acme.com).
  3. Then, add a vercel.json file like below.
  4. Finally, deploy your application to production.
{
  "redirects": [
    { "source": "/", "destination": "https://acme.com/app" }
  ]
}

An example redirect object configuration inside vercel.json.

When a request is made to app.acme.com, the proxy server will redirect to acme.com/app.

Updated October 7th 2020