Netlify site point to another Netlify site

Hello.

I have a Netlify set up for my website mikewgd.com (repo a) and I have another repo and site for my javascript projects mikewgd-myjs (repo b).

Is it possible to set up a subdomain on repo a that points to repo b? So for example have myjs.mikewgd.com and it would respect any branch subdomains from repo b?

For example I have a branch on repo b called ie67. Would it be possible to have i67.myjs.mikewgd.com, myjs.mikewgd.com ?

Thanks.

Hi, @mikewgd. The answer is “yes”.

To do this, first link the subdomain myjs.mikewgd.com to the Netlify site for repo b. Then use the branch subdomain feature to enable the branch names as subdomain from the site’s primary domain (which would be myjs.mikewgd.com in this case). Then the branch ie67 would be available as i67.myjs.mikewgd.com.

​Please let us know if there are other questions about this.

Ok, great!

So I do have https://mikewgd.netlify.com/ (repo A) and https://mikewgd-myjs.netlify.com/ (repo B).

Would I need to set up a CNAME on repo A that points to repo B Netlify URL? I tried that but it did not work.

I also tried adding a domain alias on repo A that was myjs.mikewgd.com and that did not work as well. However it still shows up DNS for repo A as myjs.mikewgd.com 3600 IN NETLIFY but I can not seem to get rid of it. Anyway to get rid of that since I removed the alias?

And if I do all this would Netlify know that any sub subdomain that is off of myjs.mikewgd.com it will point to repo B? So for example i67.myjs.mikewgd.com would always point to repo B? But if I had test.mikewgd.com that would always point to repo A?

If that makes sense?

Thanks!

Would I need to set up a CNAME on repo A that points to repo B Netlify URL? I tried that but it did not work.

The CNAME record shouldn’t be needed. Just add the custom subdomain to Site Name > Settings > Domain management > Custom domain.

Note, the branch subdomains will be based on the primary custom domain for a site (each site only has one primary custom domain).

Here are some examples to clarify a with a pretend branch named “staging”

  • primary custom domain - staging subdomain
  • mikewgd.com - staging.mikewgd.com
  • www.mikewgd.com - staging.www.mikewgd.com
  • myjs.mikewgd.com - staging.myjs.mikewgd.com

Again, this is just to clarify that the branch subdomain name will be the branch name appended to the primary custom domain (whatever that may be set to).

I also tried adding a domain alias on repo A that was myjs.mikewgd.com and that did not work as well. However it still shows up DNS for repo A as myjs.mikewgd.com 3600 IN NETLIFY but I can not seem to get rid of it. Anyway to get rid of that since I removed the alias?

The NETLIFY type DNS records are system records and can only be deleted by our support team at this time. The CNAME shouldn’t be required. If you add the domain to the sites custom domain settings, Netlify will use that setting not the NETLIFY record setting. So add the domain in the same place (Site Name > Settings > Domain management > Custom domain) and delete the CNAME record.

We can delete the NETLIFY type record too if you want us to but that isn’t technically required if you use the method above (it will work even with the NETLIFY record in place).

And if I do all this would Netlify know that any sub subdomain that is off of myjs.mikewgd.com it will point to repo B? So for example i67.myjs.mikewgd.com would always point to repo B? But if I had test.mikewgd.com that would always point to repo A?

The domains and subdomain are linked to the site (technically speaking) and not the repo itself. The domains are linked to sites in the place listed above (Site Name > Settings > Domain management > Custom domain).

If you make myjs.mikewgd.com the primary domain for repo B (or “site B” as the domain is linked to the site not the repo), the branch subdomains will always be under myjs.mikewgd.com for that site (aka repo). If you want test.mikewgd.com to be used for repo A, add that custom domain to the site domain settings and that is what Netlify will do.

I do see an edge case where you have a primary custom domain of mikewgd.com for repo C and then create a branch named myjs so that myjs.mikewgd.com would be a branch subdomain for repo C. In this case, I’m not sure which would take precedence (but we could test to see what happens). I don’t think that applies in this case, but if you think it might we can research that further.

@luke That worked! A lot simpler than I thought it would be. Thank you again! :smile: