Development Blog With Code Updates : Developercast.com

May 27, 2008

John Rockefeller’s Blog: PHP Tricks: How To Handle Multiple Domains

Filed under: Development — @ 12:11 pm

John Rockefeller has a tip he’d like to share with all of the other PHP developers out there – a little method he’s come up with to host multiple domains off of the same code.

This is really handy for those of us who have the same code handling multiple sites or multiple sub-domains. A case in point: When I coded NetBoardz (my free forum hosting service now defunct), I had one codebase handling all 250 forums. How? Simple. When the code runs, it determines which site the user is loading and does different things (like using different databases) dynamically.

He shows the two key points to dividing things up – grabbing the domain and subdomain they were trying to access. This can be fed into a script that can switch things like layout or even functionality based on which site they’ve chosen.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress