Any ideas for coding subdomains?

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
ibizconsultants
Forum Commoner
Posts: 35
Joined: Tue Sep 07, 2004 12:07 pm

Any ideas for coding subdomains?

Post by ibizconsultants »

Hello All,

I am about to develop a site with multiple domains....

e.g.

service1.domainname.com
service2.domainname.com
service3.domainname.com

As all my config files are common across the site, how do I code this.

Can any one help me with tips and ideas of how to go about doing this.

Thanks in advance.

iBizConsultants
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the actual server paths remain the same, so you can include the files fairly easily. The only things you have to consider are ones like cookies getting the right settings on the domain parameter, and links that are common. Commonly generated links (those generated by your core stuff) should be written to either use relative urls or $_SERVER['HTTP_HOST'].
ibizconsultants
Forum Commoner
Posts: 35
Joined: Tue Sep 07, 2004 12:07 pm

Post by ibizconsultants »

Thank you for your reply...

Do I have to arrange files under folders for different subdomains... i.e. should each subdomain have its individual folder.... ?

Do you have a tutorial explaining this?

Thanks
iBizConsultants
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that all depends on your hosting configuration. Most hosts I've run into (that allow subdomains) automatically generate a subdirectory of the main publichtml folder matching that subdomain name. This means that the subdomain content can be accessed via domain.com/subdomain and subdomain.domain.com. When I run subdomains, having common files, I store the common files in some central area and use an absolute path to that folder for the first inclusion. The scripts contained in there are able to figure out where they are, and how they are being accessed, so they change to whatever they need to for each instance of calling.
ibizconsultants
Forum Commoner
Posts: 35
Joined: Tue Sep 07, 2004 12:07 pm

Post by ibizconsultants »

Thank you for the prompt help....

I will get back to you if I have more questions....

Thanks again
iBizConsultants
Post Reply