Subdomains for clients

Hi there,

Beyond standard setup of a domain my knowledge is… limited, and I’m hoping someone can point me in the right direction :S

I’ve set up test project (intense-tor-86769), with a custom domain form external registrar, using Netlify DNS, this part is done.

A requirement for the project is users will have their own subdomain, and potentially their own custom domain.

The user is able to create a new post… mywebsite.com/user/postid. This part is done too.

Now moving onto the hosting stuff, totally new to all of this, I’m at a complete loss of how to point that postid to a subdomain. I need to programatically create a subdomain of that postid (postid.mywebsite.com) to display the postid page, adding a redirect to that postid page to the newly created subdomain.

Additionally I need to try figure out how to allow ‘anotherwebsite.com’ to show the content of ‘postid.mywebsite.com’.

I don’t know if this is a mammoth task or something fairly straight forward, as much as I read I’m not figuring it out! Any help would be massively appreciated!

I’ve got as far as manually creating subdomain.mywebsitesite.com, which just shows the contents of mywebsite.com. Not sure how to make it show anything different lol.

Thanks!

Hey @lemongrab,

Firstly – be careful. Reselling our service on the Starter plan is not permitted.

That out of the way… it looks like you want to enable wildcard subdomains! Wildcard subdomains aren’t enabled by default and can only be enabled from our end. There are a few requirements before we’re able to do so:

  1. Either you have to use Netlify DNS so we can get you a wildcard SSL cert, or you must bring a custom wildcard certificate.
  2. We can only do this for a site that’s on a paid team (see https://www.netlify.com/pricing for details).

It’s also worth noting that:

  • You can’t use domain aliases on the site with wildcard subdomains enabled, just the bare domain and subdomains under your primary domain. If you try to add a domain alias then it won’t work.
  • The primary custom domain for the site, if it is configured with both site.com and www.site.com in our UI, must be www.site.com and NOT site.com!

Once the wildcard subdomain feature is enabled, you do not need to add new subdomains under the site settings but you will need still need to create DNS records.

You could create a single wildcard DNS entry but, for your use case, you will want to create the individual DNS records to add each subdomain (like CNAMEs for subdomain-a.example.com, subdomain-b.example.com, etc.) as covered in our external DNS documentation.

Let us know if you have any Qs, whether you’d like to proceed or any of that jazz and we’d be happy to help!

Hey @Pie,

Thanks for the rapid response and info! Definitely looking to upgrade to pro once I’ve figured out what I’m doing.

Re your comments…

Domain aliases not allowed on sites with wildcard subdomains - does this mean that (if they wanted to) customersite.com can’t point to customersite(wildcard).mydomain.com?

If so, is there a programatic way to create new CNAME’s via API you could point me to?

If that’s not the case, I’d like to request wildcard subdomain once upgraded for sure.

Re primary domain, I have Netlify DNS set up with primary: ‘www.domain.com’, and ‘domain.com’ redirects to primary. Can you confirm this is correct?

I’ve added a subdomain http://sub1.ionicfireapp.com/ (just using a temp domain name and test repo for now) but it just shows http://ionicfireapp.com/. What are the next steps to make it show a ‘http://www.ionicfireapp.com/build/1’ for example?

I’ve read the configure external DNS doc, but I’m pointing registrar to Netlify DNS and I’m not sure how to achieve the above within Netlify DNS panel settings.

Deffo want to talk that Jazz out and figure this out. As before any help is massively appreciated!

Cheers!

does this mean that (if they wanted to) customersite.com can’t point to customersite(wildcard).mydomain.com?

Customersite.com can point to customersite(wildcard).mydomain.com though this would be configured via DNS records, not via the domain alias UI.

If so, is there a programatic way to create new CNAME’s via API you could point me to?

I think what you’re looking for is this:

Re primary domain, I have Netlify DNS set up with primary: ‘www.domain.com’, and ‘domain.com’ redirects to primary. Can you confirm this is correct?

That’s exactly how it should be, nice one :smile:!

I’ve added a subdomain http://sub1.ionicfireapp.com/ (just using a temp domain name and test repo for now) but it just shows http://ionicfireapp.com/. What are the next steps to make it show a ‘http://www.ionicfireapp.com/build/1’ for example?

Not too sure I understand? The whole point of everything we’re discussing right now is so that you don’t do this :sweat_smile:. As my above post, “Once the wildcard subdomain feature is enabled, you do not need to add new subdomains under the site settings but you will need still need to create DNS records.”

Because that’s what you want wildcard subdomains for. :slight_smile:

I’ve read the configure external DNS doc, but I’m pointing registrar to Netlify DNS and I’m not sure how to achieve the above within Netlify DNS panel settings.

Let us know once you have a non-Starter plan and we’ll enable the wildcard subdomains feature. Then, you’ll create CNAME records as above from here.

Ah! Sorry I added that example as an alias and not in CNAME. What I meant was…

I’ve added sub4.ionicapp.com, now as CNAME not alias. (CNAME, sub4, www.ionicapp.com). With wildcard set up I understand this part part wont be necessary. But what then does sub4 point at? Apologies if this question seems daft, I’m on square one on this. I’ve only ever used cPanel a long time ago, and setting up subdomains essentially gave me a folder to drop stuff into.

When I visit sub4.ionicapp.com now, I simply get a ‘Not found’ text. How do I have it show either a new site ‘/dist/browser2’ for example, or a particular URL of www.ionicapp.com, for example ‘www.ionicapp.com/customer4’.

Thanks again!

Before you’ve upgraded & we’ve enabled the feature, sub4.ionicfireapp.com will need to ALSO be added as a domain alias (this is different than an ALIAS DNS record - just an “additional” name in our UI), here: https://app.netlify.com/sites/intense-tor-86769/settings/domain#custom-domains

Seeing “Not Found” is meaning “Netlify does not recognize that hostname as applied to a site” which is true of that name.

One the feature Scott was talking about is enabled, you will not need to add domain aliases like that to the site, as long as they match that “anything.ionicfireapp.com” pattern (and as long as DNS points to us).