CodeIgniter Forums
adding SERVER_PORT to base_url setting function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: adding SERVER_PORT to base_url setting function (/showthread.php?tid=65221)



adding SERVER_PORT to base_url setting function - Sangwon Kim - 05-17-2016

My English is not good. Sorry about that.

What do you guys think about adding SERVER_PORT to base_url setting function in __construct() of core/Config.php

If I don't set a BASE_URL at the configuration, It doesn't works.


RE: adding SERVER_PORT to base_url setting function - chrisi1698 - 05-20-2016

hello everyone!

(05-17-2016, 12:13 AM)Sangwon Kim Wrote: My English is not good. Sorry about that.

What do you guys think about adding SERVER_PORT to base_url setting function in __construct() of core/Config.php

If I don't set a BASE_URL at the configuration, It doesn't works.

same issue here, I quickly fixed it myself by adding

PHP Code:
    if(isset($_SERVER['SERVER_PORT'])) {
        
$port $_SERVER['SERVER_PORT'];
        if(
is_https()) {
            if(
$port != 443$server_addr .= ':'.$port;
        }
        else {
            if(
$port != 80$server_addr .= ':'.$port;
        }
    } 

for CodeIgniter 3.0.6 in system/core/Config.php:101 (in __construct(), before setting $base_url)

maybe it helps, works for me in development on nginx+hhvm/fcgi and lighttpd+php-fcgi

BR, chris


RE: adding SERVER_PORT to base_url setting function - Narf - 05-20-2016

I am, yet again, stunned by the efforts people put into not filling a single configuration setting.