Page 1 of 1

how can i create subdomain names through asp script

Posted: Sun Jul 21, 2002 7:51 am
by saadatshah
how can i create subdomain names in php

hi all,
can any one tell me how can i create subdomain names for a user...when he register himself with our site...he should get the following kinda URL....

e.g

http://www.someuser.ourserver.com

now tell help me doin this on apache sweb server.....

waiting for a favourable response.....

Posted: Sun Jul 21, 2002 9:04 am
by ShrineMaster
You need to have your server set up with wildcarding for your domain...

ServerName http://www.yourdomain.com
ServerAlias yourdomain.com *.yourdomain.com

Your DNS should also support wildcard hosts.


All you need to do you parse out which user's virtual site is being viewed is parse out the $HTTP_HOST value to get the user name.

Code: Select all

$user = str_replace(".yourdomain.com", "", $host);
if (strstr($user, ".")) {
	$user = str_replace(".","",strrchr ($user, "."));
}
Good luck.