• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subdomain(s) and S_SERVER['HTTP_HOST']

#1
Hi guys,

Can you tell me if the following is a good practice or not:

I want to create a few subdomains so that they use the same application directory as the main site.

Is this correct to setup Sconfig['base_url'] = S_SERVER['HTTP_HOST'] ?

Thank you
Reply

#2
No, you should do it like this:
https://www.codeigniter.com/userguide3/i...e_303.html
Reply

#3
(12-22-2017, 09:49 AM)jreklund Wrote: No, you should do it like this:
https://www.codeigniter.com/userguide3/i...e_303.html

Thank you! Wink
Reply

#4
You can use this code
$allowed_domains = array('domain1.tld', 'domain2.tld');
$default_domain  = 'domain1.tld';

if (in_array($_SERVER['HTTP_HOST'], $allowed_domains, TRUE))
{
        $domain = $_SERVER['HTTP_HOST'];
}
else
{
        $domain = $default_domain;
}

if ( ! empty($_SERVER['HTTPS']))
{
        $config['base_url'] = 'https://'.$domain;
}
else
{
        $config['base_url'] = 'http://'.$domain;
}
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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