Can a different domain/subdomain point to a branch deploy with a CNAME?

From what I’ve read, you can point any non-apex domain to a branch deploy by adding a CNAME record on that domain with the name of the branch, i.e. <branch-name>.<custom-domain> to <branch-name>--<site-name>.netlify.com.

Would it also be possible to add another CNAME record to alias this subdomain? For example, a CNAME that points <alias>.<custom-domain> to <branch-name>.<custom-domain>?

At this time, it’s only possible to utilise the branch name for the subdomain (unless you set up another site and serve the branch separately).

I thought I’d bump this and see if this is still ‘state of the union’ for subdomain on branch deploy.

I’ve got a domain on Netlify DNS, call it example.com.
One of our branches is named app.example.com.

Another branch is currently main–example.netlify.app, but we would like to have this be staging.example.com. Currently creating a CNAME record doesn’t seem to work. Maybe I’m doing something wrong or this still isn’t possible.

Hi, @Timmy. The starting place is here:

Please note, the subdomain and the branch name must match exactly. This means that the main–example branch would need to be the subdomain main–example.example.com.

The only workaround to make that branch use a different subdomain is to make a new site. On that new site make the branch main–example the production branch. At that point any domain name can be assigned. Note, that isn’t the branch subdomain feature but it will workaround the requirement that branch name and subdomain must match.

​Please let us know if there are any questions about that support guide or the response above. If you do want to use the branch subdomain feature without Netlify DNS, please reply here when the DNS records exist and our support team will extend the SSL certificate to include those subdomains.

Thank you Luke for confirming the behavior here.

What you put jives with what I’v been reading in the guide and help sections. I was hoping there was some other way than the different site work around. But I’m sure you have good reasoning for the way this is. Thank you for the quick response.

1 Like