how can i create subdomain names through asp script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saadatshah
Forum Newbie
Posts: 23
Joined: Fri Jul 05, 2002 5:50 am
Location: Lahore

how can i create subdomain names through asp script

Post 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.....
ShrineMaster
Forum Newbie
Posts: 7
Joined: Mon May 20, 2002 5:33 am

Post 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.
Post Reply