April 8, 2025

Subdomain Redirects to External URL using Vercel DNS


Overview

While recently migrating from Cloudflare DNS to Vercel DNS (obviously), I realized quickly I wasn't exactly sure how to redirect my subdomains (like linkedin.sather.ws to an external URL like https://www.linkedin.com/in/willsather) as I previously just relied on Cloudflare's rules.

The reason I'm writing this today is that to achieve this exact behavior, I had to combine this GitHub discussion answer with three different Vercel community guides (one, two, and three).

In retrospect, this really isn't that difficult but it took long enough to test that I wish someone had just explained it for me.

Vercel Configuration

To define the redirects for Vercel, you can provide a vercel.json configuration file alongside your project just like this:

vercel.json
{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "redirects": [
    {
      "source": "/",
      "has": [
        {
          "type": "host",
          "value": "linkedin.sather.ws"
        }
      ],
      "destination": "https://www.linkedin.com/in/willsather"
    }
  ]
}
json

The documentation for this configuration file can be found here.

2. Add Subdomain URL to Project

Assuming this project is already pushed to Vercel, go to Vercel Dashboard > {Select your Project} > Settings > Domains > Add Domain, you can add a new

Vercel Add Subdomain

and after confirmation:

Vercel Add Subdomain

3. Add CNAME Record to DNS

  1. Go to Vercel Dashboard > Domains.

  2. Select your domain (in my case, sather.ws).

  3. Create a new CNAME record with the name of your subdomain and value of cname.vercel-dns.com like this:

    Vercel DNS Records

4. All Set!

Now, when someone visits https://linkedin.sather.ws, they will be redirected to my LinkedIn profile, but this is applicable for any external url you would like!