views:

21

answers:

2

I'd like to produce regional versions of a php powered website, for example:

www.mysite-england.co.uk 
www.mysite-wales.co.uk 
www.mysite-scotland.co.uk 

I'd like to setup one LAMP server to serve all the domains with a single php MVC using $_SERVER['HTTP_HOST'] (or similar) as the primary content modifier. Ie

if($_SERVER['HTTP_HOST'] == 'mysite-wales.co.uk'){
   $region =    'wales';
   $database =  'db_wales';
   $styles=     array('wales.css', 'wales_banners.css')
   etc etc....    
}

How do i go about setting up the server to direct all these domains to the same MVC router on a single server?

+2  A: 

Configure the Apache virtual host for the main site, and use the ServerAlias directive so it accepts connections for your other domains.

<VirtualHost *:80>
ServerName mysite-england.co.uk
ServerAlias *.mysite-england.co.uk *.mysite-wales.co.uk mysite-wales.co.uk *.mysite-scotland.co.uk mysite-scotland.co.uk
DocumentRoot /www/mysite
</VirtualHost>

More information:

Craig A Rodway
A: 

We did this a lot at my last job. All you do is in the vhost point all the domains at the same code base. The code base will not care what the difference is except where you define variables (I.E. Site Name, Region). Just add the server aliases to your vhost and run a switch at the top of your bootstrap.

Christian South