making use of subdomains

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
modr8
Forum Newbie
Posts: 3
Joined: Wed Oct 22, 2003 1:11 pm

making use of subdomains

Post by modr8 »

Hopefully I'm in the right area for this,

I have built a blogg-style site for some friends and myself using PHP and MySQL. I want to use subdomain so that each user has a unique URL i.e

user1.website.com
user2.website.com

the problem is I'm having trouble working out a way to direct the subdomains to the main set of php files, to activate a subdomain I make a folder in the FTP root called user1.website.com and place whatever files I would like in there.

at the moment I have placed a copy of the php files in each folder and I get the subdomain to tell the code who's site it is, but obviously this is bulky and it means if I want to make a change I have to update the page in every folder.

I have thought of using includes, but this still reqires a file for each include, I have also tried to use frames but I can't access the subdomain name from a page stored 'outside' the subdomain.

sorry if it's a bit scattered, I think it's an interesting topic on backend site design and also hopefully a solution for my needs.

thanks for any ideas
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

a much more efficient way would be to use wildcard dns so that *.domain.com goes to the same place, then add some logic in your script to determine what user it is from the HTTP_HOST environment variable..
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

btw if you do want separate folders and fixed domains (not very useful for a generic software, thousands of users etc), use apache's mod_rewrite to redirect apache to the right file..
modr8
Forum Newbie
Posts: 3
Joined: Wed Oct 22, 2003 1:11 pm

Post by modr8 »

thanks for the wildcard idea, I have been playing around with it and it seems to be working well.

i'll keep you uptodate!
Post Reply