Simple Mass Virtual Hosting

Using CPanel, WHM, shell Access (or plesk), DNS

Prerequisites:

  • Shell Access (or ability to edit the httpd.conf)
  • DNS editing access
  • Wildcard DNS ability
  • PHP!
* We use www.domain.tld as an example. Modify to suit.
First, make sure that your www.domain.tld works as normal

Second, enable wildcard DNS by (various means, depending on your interface). But you should see something like
* 14400 A xxx.xxx.xxx.xxx
where xxx.xxx.xxx.xxx is your NS ip address (should be the same as the one in the www A record)

Third, change/add the ServerAlias directive in your httpd.conf file to something like
ServerAlias *.domain.tld
You should see now that all addresses, *.domain.tld will be redirected internally to www.domain.tld

Last, use Php’s $HTTP_HOST command and explode and you’re done!