CodeIgniter Forums
updated to current ci but base_url() defect - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: updated to current ci but base_url() defect (/showthread.php?tid=67814)



updated to current ci but base_url() defect - cupboy1 - 04-12-2017

the base_url function does not return the port number like it used to
What can I use instead?


RE: updated to current ci but base_url() defect - php_rocs - 04-14-2017

@cupboy1

How is your base url defined in your config file?


RE: updated to current ci but base_url() defect - cupboy - 04-14-2017

It's blank in both config files (older version, and current version). Definitely a bug with the new codeignitor version. I don't know what older version I'm currently running but it's a version 3 version, just not the latest one. My IIS settings are correct.


RE: updated to current ci but base_url() defect - ciadmin - 04-14-2017

Not a bug with either CodeIgniter or codeignitor:
https://www.codeigniter.com/user_guide/installation/upgrade_300.html?highlight=base_url#step-19-make-sure-your-base-url-config-value-is-not-empty


RE: updated to current ci but base_url() defect - cupboy - 04-14-2017

I was able to fix it by going into system/core/Config.php and changing __construct to do it the old way, using  $__SERVER['HTTP_HOST'] instead of the new, non-working way which used $__SERVER['SERVER_ADDR']

Hasn't been thoroughly tested yet but works so far.

Now that I've gotten a way into the site I get a new error:

Call to a member function unset_userdata() on null

Strange stuff.


RE: updated to current ci but base_url() defect - ciadmin - 04-14-2017

Never a good idea to mess with code in system. The change was made because using HTTP_HOST can lead to a host header injection attack.

If you absolutely want to do it "your way", the proper approach would be to "extend" the Config class ... https://www.codeigniter.com/user_guide/general/core_classes.html#extending-core-class


RE: updated to current ci but base_url() defect - cupboy - 04-14-2017

I've taken a look at that. I intend to study it further.