CodeIgniter Forums
Multi domain in CodeIgniter with http/https - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forum-9.html)
+--- Thread: Multi domain in CodeIgniter with http/https (/thread-66430.html)



Multi domain in CodeIgniter with http/https - d4jk4 - 10-21-2016

Hi all,

I have been used CI for 4 years. Today I will share my config for multi domain + http/https

The environment: CI 2.x/3.x + nginx web server

- In server side (nginx), you should config normal vhost for http/https (you can search with Google)
- In Application side, file config.php


PHP Code:
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
    $protocol_ 'https';
else
    $protocol_ 'http';
$config['base_url'] = $protocol_.'://'.$_SERVER['HTTP_HOST'].'/'

Now you can access your application with many domain:
http://abc.com/
https://abc.com/
**SEO SPAM LINK REDACTED**
http://xyz.com/
https://xyz.com/
And no need config any more in application side

Hope all you like this topic Wink