Mobile app version of vmapp.org
Login or Join
Sue5673885

: How to create a subdomain using a script How can one create a new subdomain using a script? Creating a new database or database table is something I'm familiar with. If this is not possible,

@Sue5673885

Posted in: #Script #Subdomain #WebHosting

How can one create a new subdomain using a script? Creating a new database or database table is something I'm familiar with.

If this is not possible, how does About.com create all the subdomains they use. Is it manually, or some other way?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Sue5673885

2 Comments

Sorted by latest first Latest Oldest Best

 

@Gretchen104

If you are using cPanel you can use the xmlapi class github.com/CpanelInc/xmlapi-php.
You then invoke it like this:

require("xmlapi.php"); // this can be downloaded from github.com/CpanelInc/xmlapi-php/blob/master/xmlapi.php $xmlapi = new xmlapi("your-primary-domain.com");
$xmlapi->set_port( 2083 );
$xmlapi->password_auth('username','password'); //cpanel credentials
$xmlapi->set_debug(0);//output actions in the error log 1 for true and 0 false

// create subdomain
print $xmlapi->api1_query('accountname','SubDomain','addsubdomain',array('subdomain.domain.com',0,0,'/public_html/location.of.the.web.files'));

10% popularity Vote Up Vote Down


 

@Mendez628

What exactly do you mean by subdomain? Just the entry in the DNS System or the whole handling of the subdomain (which is just a hostname).

You can set a wildcard DNS entry so every hostname.yourdomain.com is set to your webserver e.g.:

*.example.com IN A 123.123.123.123

so everything.example.org would be resolved to 123.123.123.123 except you specified a entry for the URL.

Your Apache vhost needs to accept every hostname of the domain

ServerName example.com
ServerAlias *.example.com

Everything else is handled by .htaccess files using mod_rewrite and PHP routers.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme