-1

I am using cPanel api2+uapi to handle my domain to be very specific to create subdomain.

My subdomain is creating successfully there is no problem at all but its not getting activated instantly like how Shopify gives their users a subdomain instantly after user submits the store creation form.

I contacted my service provider about this issue they told me that cPanel users have to wait at least 5 minutes or even it would take 30/40 minutes to go live. So my question is:

  1. How is Shopify is creating subdomains instantly?
  2. If it's not possible in cPanel how can it be done? Or, in other words: how can I create a subdomain instantly using PHP?
Cameron Hurd
  • 4,836
  • 1
  • 22
  • 31
Mmd Mahbub
  • 53
  • 1
  • 10

1 Answers1

1

You can skip the cPanel API hits to create explicit subdomains and instead use a wildcard domain with multitenancy.

If your domain is foo.com then you can set up a DNS entry for *.foo.com that points to your app's IP(s). When your app takes an order, you write the new domain into the database and tell the customer their domain is whatever.foo.com which instantly resolves to your app. Your app can then look at the HOST header to determine what domain was requested, and act accordingly.

Alex Howansky
  • 50,515
  • 8
  • 78
  • 98
  • And this is how you would do it on cPanel? – Robert Harvey Dec 20 '18 at 16:18
  • 1
    A word of caution though: DNS wildcards should be used only by people already quite knowledgable with DNS otherwise all sorts of problems may arise, even more if using DNSSEC. – Patrick Mevzek Dec 20 '18 at 16:19
  • I have got everything instead the host header part,here is the process I have done - 1. I have created a wildcard subdomain which is pointing on public_html 2. I have saved the user data into database 3. Now every time my user register I am creating a folder on public_html for them as they can use my app separately like they can install WordPress or whatever they like. But now when i visit by foo.domain.com it shows every folder inside this folder. How can I solve this should I write any .htaccess file ? @alex – Mmd Mahbub Dec 22 '18 at 20:35