CodeIgniter Forums
One Codeingniter installation. Multiple parked domains - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: One Codeingniter installation. Multiple parked domains (/showthread.php?tid=39492)



One Codeingniter installation. Multiple parked domains - El Forum - 03-11-2011

[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!


One Codeingniter installation. Multiple parked domains - El Forum - 03-11-2011

[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]....
}
?>



One Codeingniter installation. Multiple parked domains - El Forum - 03-13-2011

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