One Codeingniter installation. Multiple parked domains

#1
[eluser]Andy UK[/eluser]
I have a single Codeigniter installation, but various parked domains that lead to that one installation.

I need to read which domain the user arrives by in order to feed the right Google Maps API key to the application (a different key for each domain)

Is there a way to read the domain name and what should be done about the domain name registered in the config file. Can more than one domain name be used in a single installation?

Thanks in advance!

#2
[eluser]theprodigy[/eluser]
Take a look at the $_SERVER variable docs. It will give you the domain name that the user came in on.
Code:
<?php
$_SERVER['SERVER_NAME'];
?>

In your config file, just do something like:
Code:
<?php
$domain = explode('.', $_SERVER['SERVER_NAME'];
if($domain[0] == 'www')
{
    array_shift($domain);
}

switch(implode('.', $domain)
{
    case 'mydomain.com':
        $map_key = 'this_is_my_map';
        break;
    case 'mydomain.net':
        $map_key = 'this_is_my_other_map';
        break;
    ....[continue cases]....
}
?>

#3
[eluser]Andy UK[/eluser]
Cheers! That worked nicely Big Grin


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.