Subdomain(s) and S_SERVER['HTTP_HOST'] |
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
No, you should do it like this:
https://www.codeigniter.com/userguide3/i...e_303.html (12-22-2017, 08:49 AM)jreklund Wrote: No, you should do it like this: Thank you!
12-24-2017, 09:06 AM
(This post was last modified: 12-26-2017, 08:49 AM by ciadmin. Edit Reason: SEO spam )
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; } |
Welcome Guest, Not a member yet? Register Sign In |