• SupportDNS
  • CNAME my website's users' custom domain to their subdomains of my domain ?

Lets say I wanted to setup a website at myWeb.com where users can map their user-pages to subdomains like jack.myWeb.com and jill.myWeb.com

If jack wants his user-page to be mapped to his own domain jack.com and jill wants to do the same at jill.com., what would they need to do ? CNAME jack.com to jack.myWeb.com and CNAME jill.com to jill.myWeb.com ?

Is this all ? Straightforward ?

  • sean replied to this.

    anjanesh you can't create CNAMEs on apex domains.

    For this to work your app will need to route the custom domains to their respective user sites, ie check the Host header and route accordingly.

    Do you have any references / links to do this in PHP ? - I am some difficulty in getting the right search terms for googling.

    • sean replied to this.

      anjanesh I do not have any reference. What type of application is it?

      Lets say I wanted to build a PHP version of blogger.com - now my blog is at
      lghwggqix3exhrwdlpeextsgu3htx7ya0ls.blogspot.com
      for which my custom domain code.anjanesh.net is CNAMED to ghs.google.com

      This is what I want to achieve in a PHP application.

      • sean replied to this.

        anjanesh in PHP you can get the host header from $_SERVER['HTTP_HOST'].

        The rest of it is up to you, you'll need to have some sort of data structure linking hostnames to users so that you can then serve whichever user's content for a given hostname. You'll probably also need to hook into our API to route the user domains to your site.

        Thanks for your response Sean - somehow I thought CNAME was the way to go.

        • sean replied to this.

          anjanesh you can still point subdomains at your Opalstack site subdomain with CNAMES, but since we use name-based virtual hosting in our Nginx setup the CNAME subdomains have to be routed to your site like any other domain or subdomain.

          Mastodon