Multi-tenency subdomain support

I’m trying to implement multi-tenency in my application and allowing users to create their own subdomains. Through googling, it seems that PRO would support this use case?

Before I purchase pro, I’d just like to confirm whether I can accomplish either of these solutions:

Preferred solution:
Show xxx.mydomain.com but render my application as if it were mydomain.com/n/xxx. I’m not even sure this makes sense in a SPA context, but this would allow me do not make any changes to my React app as I already support mydomain.com/n/xxx.

Second solution:
Have a wildcard subdomain at *.mydomain.com that redirects all traffic to mydomain.com. I only want to have one netlify application to maintain and have all subdomains redirect to it. I want to keep the URL as *.mydomain.com.

Lastly, would it be possible to have anotherdomain.com point to anotherdomain.mydomain.com?

This ticket seems to indicate no: Wildcard Subdomain

If I did create a new site for each domain, would I be able to use the Netlify API to automate this?

Hi, @achan, and welcome to the Netlify community site. :smiley:

I am going to reply to each option/question inline for clarity.

Preferred solution:
Show xxx.mydomain.com but render my application as if it were mydomain.com/n/xxx. I’m not even sure this makes sense in a SPA context, but this would allow me do not make any changes to my React app as I already support mydomain.com/n/xxx.

This is possible using redirects. You would need to manually create each rule. There is no way to match a subdomain and reuse that elsewhere in the redirect rule. So this does not work:

https://:subdomain.mydomain.com/* https://mydomain.com/n/:subdomain/:splat 200!

Again, the rule above will not work. However, you can create a rule for each subdomain and this does work. This would looks similar to this:

https://one.mydomain.com/* https://mydomain.com/n/one/:splat 200!
https://two.mydomain.com/* https://mydomain.com/n/two/:splat 200!

Second solution:
Have a wildcard subdomain at *.mydomain.com that redirects all traffic to mydomain.com. I only want to have one netlify application to maintain and have all subdomains redirect to it. I want to keep the URL as *.mydomain.com.

Yes, this is possible on Pro level plans and is the “wildcard subdomain” feature. It can only be enabled by our support team at this time. It can be used in combination with the redirect rules above also if you want to do so.

Lastly, would it be possible to have anotherdomain.com point to anotherdomain.mydomain.com?

This ticket seems to indicate no: Wildcard Subdomain

This is not possible when using wildcard subdomains. If this feature is enabled, only the wildcard domain can be used with this site.

If you are not using wildcard subdomains, then the option above does work.

If I did create a new site for each domain, would I be able to use the Netlify API to automate this?

Yes, you can use our API programmatically to create sites and change site settings. Our terms of service do allow for this.

If there are other questions, please let us know.