create subdomain programatically in PHP -


i on shared hosting , on add on domain.

i need create subdomain each user of website if username jeff should have url jeff.mydomain.com.

how can create programatically using php?

thanks prady

there's 2 parts this. firstly you'll need setup wildcard dns entry.

once you've got setup should have requests pointed single domain. there can use php figure out domain you're on:

$domain = $_server['http_host']; $base = 'mydomain.com'; $user = substr($domain, 0, -(strlen($base)+1));// user part of domain if(!empty($user)) {   $user = sanatiseuser($user);   require_once $user.'.php'; } 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -