#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:
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"redirects": [
{
"source": "/",
"has": [
{
"type": "host",
"value": "linkedin.sather.ws"
}
],
"destination": "https://www.linkedin.com/in/willsather"
}
]
}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
and after confirmation:
#3. Add CNAME Record to DNS
-
Go to Vercel Dashboard > Domains.
-
Select your domain (in my case,
sather.ws). -
Create a new
CNAMErecord with thenameof your subdomain andvalueofcname.vercel-dns.comlike this:
#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!