PHP - how do i create subdomain automatically - Asked By Olusegun A. on 26-Oct-10 10:51 AM

Hello friends,
i want a situation whereby when members confirm his registration a subdomain will be automatically created. eg if a member by name Mike Lawrence confirm his registration, a subdomain like www.mydomain.com/mikelawnrece OR mikelawrence.mydomain.com will be created, so that anyone can visit his profile by entering the subdomain in any address bar. pls what are the easiest ways of doing this.
anil soni replied to Olusegun A. on 26-Oct-10 02:00 PM
Whenever a subdomain is requested by a client the domain root directory default page is returned by the web server. In short you can programatically check for the request URI in index.php of your root directory and redirect the page or you can generate page accordingly.

E.g. When subdomain.domain.com is request from the client browser, webserver will return default page i.e. index.php for domain.com

if($_SERVER['REQUEST_URI']=="subdomain.domain.com")
  header('location: subdomain.php');