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
Now you can access your application with many domain:
http://abc.com/
https://abc.com/
http://xyz.com/
https://xyz.com/
And no need config any more in application side
Hope all you like this topic
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/
http://xyz.com/
https://xyz.com/
And no need config any more in application side
Hope all you like this topic