Skip to content

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 commonly used for subpaths. For example, adding a redirect from to

If you want to rewrite to, you'll need to configure a rewrite making use of the has field.

Configuring a Rewrite with 'has' Field

  1. Create a next.config.js file is using Next.js or a vercel.json file like below.
  2. Push your changes and redeploy your application.
rewrites() { return { beforeFiles: [ // if the host is ``, // this rewrite will be applied { source: '/:path*', has: [ { type: 'host', value: '', }, ], destination: '/app/:path*', }, ] } }

An example rewrite object configuration inside next.config.js.. Only paths with will be rewritten.

{ "rewrites": [ { "source": "/:path*", "has": [ { "type": "host", "value": "" } ], "destination": "/app/:path*" } ] }

An example rewrite object configuration inside vercel.json.

When a request is made to, then it will be rewritten to

Couldn't find the guide you need?