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:
- How is Shopify is creating subdomains instantly?
- 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?
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 iswhatever.foo.com
which instantly resolves to your app. Your app can then look at theHOST
header to determine what domain was requested, and act accordingly.